mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ipv6_addr: remove ng_ prefix
This commit is contained in:
parent
9aa96509ee
commit
203561e741
@ -70,7 +70,7 @@ ifneq (,$(filter ng_sixlowpan,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_sixlowpan_ctx,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += vtimer
|
||||
endif
|
||||
|
||||
@ -130,7 +130,7 @@ endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6,$(USEMODULE)))
|
||||
USEMODULE += inet_csum
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += ng_ipv6_hdr
|
||||
USEMODULE += ng_ipv6_nc
|
||||
USEMODULE += ng_ipv6_netif
|
||||
@ -138,11 +138,11 @@ ifneq (,$(filter ng_ipv6,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_nc,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ng_ipv6_netif,$(USEMODULE)))
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += ng_netif
|
||||
endif
|
||||
|
||||
|
@ -36,11 +36,11 @@ static void send(char *addr_str, char *port_str, char *data)
|
||||
uint8_t port[2];
|
||||
uint16_t tmp;
|
||||
ng_pktsnip_t *payload, *udp, *ip;
|
||||
ng_ipv6_addr_t addr;
|
||||
ipv6_addr_t addr;
|
||||
ng_netreg_entry_t *sendto;
|
||||
|
||||
/* parse destination address */
|
||||
if (ng_ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("Error: unable to parse destination address");
|
||||
return;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ endif
|
||||
ifneq (,$(filter ng_ipv6,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6
|
||||
endif
|
||||
ifneq (,$(filter ng_ipv6_addr,$(USEMODULE)))
|
||||
DIRS += net/network_layer/ng_ipv6/addr
|
||||
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
|
||||
|
39
sys/include/net/ipv6.h
Normal file
39
sys/include/net/ipv6.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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 IPv6
|
||||
* @ingroup net
|
||||
* @brief Provides types and helper functions related to Internet Protocol
|
||||
* version 6 (IPv6)
|
||||
* @see <a href="http://tools.ietf.org/html/rfc2460">
|
||||
* RFC 2460
|
||||
* </a> et al.
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief IPv6 include gathering header.
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef IPV6_H_
|
||||
#define IPV6_H_
|
||||
|
||||
#include "ipv6/addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* IPV6_H_ */
|
||||
/** @} */
|
@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup net_ng_ipv6_addr IPv6 addresses
|
||||
* @ingroup net_ng_ipv6
|
||||
* @defgroup net_ipv6_addr IPv6 addresses
|
||||
* @ingroup net_ipv6
|
||||
* @brief IPv6 address architecture
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc4291">
|
||||
@ -24,8 +24,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NG_IPV6_ADDR_H_
|
||||
#define NG_IPV6_ADDR_H_
|
||||
#ifndef IPV6_ADDR_H_
|
||||
#define IPV6_ADDR_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -38,12 +38,12 @@ extern "C" {
|
||||
/**
|
||||
* @brief Length of an IPv6 address in bit.
|
||||
*/
|
||||
#define NG_IPV6_ADDR_BIT_LEN (128)
|
||||
#define IPV6_ADDR_BIT_LEN (128)
|
||||
|
||||
/**
|
||||
* @brief Maximum length of an IPv6 address as string.
|
||||
*/
|
||||
#define NG_IPV6_ADDR_MAX_STR_LEN (sizeof("ffff:ffff:ffff:ffff:" \
|
||||
#define IPV6_ADDR_MAX_STR_LEN (sizeof("ffff:ffff:ffff:ffff:" \
|
||||
"ffff:ffff:255.255.255.255"))
|
||||
|
||||
/**
|
||||
@ -57,7 +57,7 @@ extern "C" {
|
||||
* href="http://tools.ietf.org/html/rfc3879">SLDEP</a>. They are only
|
||||
* defined here for the distinction of global unicast addresses.
|
||||
*/
|
||||
#define NG_IPV6_ADDR_SITE_LOCAL_PREFIX (0xFEC0)
|
||||
#define IPV6_ADDR_SITE_LOCAL_PREFIX (0xfec0)
|
||||
|
||||
/**
|
||||
* @brief Data type to represent an IPv6 address.
|
||||
@ -67,7 +67,7 @@ typedef union {
|
||||
network_uint16_t u16[8]; /**< divided by 8 16-bit words. */
|
||||
network_uint32_t u32[4]; /**< divided by 4 32-bit words. */
|
||||
network_uint64_t u64[2]; /**< divided by 2 64-bit words. */
|
||||
} ng_ipv6_addr_t;
|
||||
} ipv6_addr_t;
|
||||
|
||||
/**
|
||||
* @brief Static initializer for the unspecified IPv6 address (::)
|
||||
@ -76,7 +76,10 @@ typedef union {
|
||||
* RFC 4291, section 2.5.2
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_UNSPECIFIED {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }}
|
||||
#define IPV6_ADDR_UNSPECIFIED {{ 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00 }}
|
||||
|
||||
/**
|
||||
* @brief Static initializer for the loopback IPv6 address (::1)
|
||||
@ -85,8 +88,10 @@ typedef union {
|
||||
* RFC 4291, section 2.5.3
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_LOOPBACK {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }}
|
||||
|
||||
#define IPV6_ADDR_LOOPBACK {{ 0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x01 }}
|
||||
/**
|
||||
* @brief Static initializer for the interface-local all nodes multicast IPv6
|
||||
* address (ff01::1)
|
||||
@ -95,8 +100,10 @@ typedef union {
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_NODES_IF_LOCAL {{ 0xff, 0x01, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 1 }}
|
||||
#define IPV6_ADDR_ALL_NODES_IF_LOCAL {{ 0xff, 0x01, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x01 }}
|
||||
|
||||
/**
|
||||
* @brief Static initializer for the link-local all nodes multicast IPv6
|
||||
@ -106,8 +113,10 @@ typedef union {
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL {{ 0xff, 0x02, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 1 }}
|
||||
#define IPV6_ADDR_ALL_NODES_LINK_LOCAL {{ 0xff, 0x02, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x01 }}
|
||||
|
||||
/**
|
||||
* @brief Static initializer for the interface-local all routers multicast IPv6
|
||||
@ -117,8 +126,10 @@ typedef union {
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_ROUTERS_IF_LOCAL {{ 0xff, 0x01, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 2 }}
|
||||
#define IPV6_ADDR_ALL_ROUTERS_IF_LOCAL {{ 0xff, 0x01, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x02 }}
|
||||
|
||||
/**
|
||||
* @brief Static initializer for the link-local all routers multicast IPv6
|
||||
@ -128,8 +139,10 @@ typedef union {
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL {{ 0xff, 0x02, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 2 }}
|
||||
#define IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL {{ 0xff, 0x02, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x02 }}
|
||||
|
||||
|
||||
/**
|
||||
@ -140,68 +153,73 @@ typedef union {
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
#define NG_IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL {{ 0xff, 0x05, 0, 0, 0, 0, 0, 0, \
|
||||
0, 0, 0, 0, 0, 0, 0, 2 }}
|
||||
#define IPV6_ADDR_ALL_ROUTERS_SITE_LOCAL {{ 0xff, 0x05, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x00, \
|
||||
0x00, 0x00, 0x00, 0x02 }}
|
||||
|
||||
/**
|
||||
* @name Multicast address flags
|
||||
* @brief Values for the flag field in multicast addresses.
|
||||
* @{
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc4291#section-2.7">
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* @brief The address is transient, i.e. not well-known, permanantly
|
||||
* assigned address by IANA.
|
||||
*/
|
||||
NG_IPV6_ADDR_MCAST_FLAG_TRANSIENT = 0x01,
|
||||
|
||||
/**
|
||||
* @brief The address is based on a network prefix
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc3306#section-4">
|
||||
* RFC 3306, section 4
|
||||
* </a>
|
||||
*/
|
||||
NG_IPV6_ADDR_MCAST_FLAG_PREFIX_BASED = 0x02,
|
||||
|
||||
/**
|
||||
* @brief The address embeds the address on the rendezvous point
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc3956#section-3">
|
||||
* RFC 3956, section 3
|
||||
* </a>
|
||||
*/
|
||||
NG_IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP = 0x04,
|
||||
} ng_ipv6_addr_mcast_flag_t;
|
||||
/**
|
||||
* @brief The address is transient, i.e. not well-known, permanantly
|
||||
* assigned address by IANA.
|
||||
*/
|
||||
#define IPV6_ADDR_MCAST_FLAG_TRANSIENT (0x01)
|
||||
|
||||
/**
|
||||
* @brief The address is based on a network prefix
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc3306#section-4">
|
||||
* RFC 3306, section 4
|
||||
* </a>
|
||||
*/
|
||||
#define IPV6_ADDR_MCAST_FLAG_PREFIX_BASED (0x02)
|
||||
|
||||
/**
|
||||
* @brief The address embeds the address on the rendezvous point
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc3956#section-3">
|
||||
* RFC 3956, section 3
|
||||
* </a>
|
||||
*/
|
||||
#define IPV6_ADDR_MCAST_FLAG_EMBED_ON_RP (0x04)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Multicast address scopes
|
||||
* @brief Values for the scope field in multicast addresses.
|
||||
* @{
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc4291#section-2.7">
|
||||
* RFC 4291, section 2.7
|
||||
* </a>
|
||||
*/
|
||||
typedef enum {
|
||||
NG_IPV6_ADDR_MCAST_SCP_IF_LOCAL = 0x1, /**< interface-local scope */
|
||||
NG_IPV6_ADDR_MCAST_SCP_LINK_LOCAL = 0x2, /**< link-local scope */
|
||||
/**
|
||||
* @brief realm-local scope
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc7346#section-3">
|
||||
* RFC 7346, section 3
|
||||
* </a> and
|
||||
* <a href="http://tools.ietf.org/html/rfc7346#section-5">
|
||||
* RFC 7346, section 5
|
||||
* </a> and
|
||||
*/
|
||||
NG_IPV6_ADDR_MCAST_SCP_REALM_LOCAL = 0x3,
|
||||
NG_IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL = 0x4, /**< admin-local scope */
|
||||
NG_IPV6_ADDR_MCAST_SCP_SITE_LOCAL = 0x5, /**< site-local scope */
|
||||
NG_IPV6_ADDR_MCAST_SCP_ORG_LOCAL = 0x8, /**< organization-local scope */
|
||||
NG_IPV6_ADDR_MCAST_SCP_GLOBAL = 0xe, /**< global scope */
|
||||
} ng_ipv6_addr_mcast_scp_t;
|
||||
#define IPV6_ADDR_MCAST_SCP_IF_LOCAL (0x1) /**< interface-local scope */
|
||||
#define IPV6_ADDR_MCAST_SCP_LINK_LOCAL (0x2) /**< link-local scope */
|
||||
|
||||
/**
|
||||
* @brief realm-local scope
|
||||
*
|
||||
* @see <a href="http://tools.ietf.org/html/rfc7346#section-3">
|
||||
* RFC 7346, section 3
|
||||
* </a> and
|
||||
* <a href="http://tools.ietf.org/html/rfc7346#section-5">
|
||||
* RFC 7346, section 5
|
||||
* </a> and
|
||||
*/
|
||||
#define IPV6_ADDR_MCAST_SCP_REALM_LOCAL (0x3)
|
||||
#define IPV6_ADDR_MCAST_SCP_ADMIN_LOCAL (0x4) /**< admin-local scope */
|
||||
#define IPV6_ADDR_MCAST_SCP_SITE_LOCAL (0x5) /**< site-local scope */
|
||||
#define IPV6_ADDR_MCAST_SCP_ORG_LOCAL (0x8) /**< organization-local scope */
|
||||
#define IPV6_ADDR_MCAST_SCP_GLOBAL (0xe) /**< global scope */
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Checks if two IPv6 addresses are equal.
|
||||
@ -212,8 +230,7 @@ typedef enum {
|
||||
* @return true, if @p a and @p b are equal
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_equal(const ng_ipv6_addr_t *a,
|
||||
const ng_ipv6_addr_t *b)
|
||||
static inline bool ipv6_addr_equal(const ipv6_addr_t *a, const ipv6_addr_t *b)
|
||||
{
|
||||
return (a->u64[0].u64 == b->u64[0].u64) &&
|
||||
(a->u64[1].u64 == b->u64[1].u64);
|
||||
@ -231,7 +248,7 @@ static inline bool ng_ipv6_addr_equal(const ng_ipv6_addr_t *a,
|
||||
* @return true, if @p addr is unspecified address
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_unspecified(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_unspecified(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (addr->u64[0].u64 == 0) &&
|
||||
(addr->u64[1].u64 == 0);
|
||||
@ -249,7 +266,7 @@ static inline bool ng_ipv6_addr_is_unspecified(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is loopback address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_loopback(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_loopback(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (addr->u64[0].u64 == 0) &&
|
||||
(byteorder_ntohll(addr->u64[1]) == 1);
|
||||
@ -267,7 +284,7 @@ static inline bool ng_ipv6_addr_is_loopback(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is an IPv4-compatible IPv6 address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_ipv4_compat(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_ipv4_compat(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (addr->u64[0].u64 == 0) &&
|
||||
(addr->u32[2].u32 == 0);
|
||||
@ -285,11 +302,11 @@ static inline bool ng_ipv6_addr_is_ipv4_compat(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is an IPv4-compatible IPv6 address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_ipv4_mapped(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_ipv4_mapped(const ipv6_addr_t *addr)
|
||||
{
|
||||
return ((addr->u64[0].u64 == 0) &&
|
||||
(addr->u16[4].u16 == 0) &&
|
||||
(addr->u16[5].u16 == 0xFFFF));
|
||||
(addr->u16[5].u16 == 0xffff));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,7 +321,7 @@ static inline bool ng_ipv6_addr_is_ipv4_mapped(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is multicast address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_multicast(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_multicast(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (addr->u8[0] == 0xff);
|
||||
}
|
||||
@ -324,11 +341,11 @@ static inline bool ng_ipv6_addr_is_multicast(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is link-local address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_link_local(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_link_local(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (byteorder_ntohll(addr->u64[0]) == 0xfe80000000000000) ||
|
||||
(ng_ipv6_addr_is_multicast(addr) &&
|
||||
(addr->u8[1] & 0x0f) == NG_IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
|
||||
(ipv6_addr_is_multicast(addr) &&
|
||||
(addr->u8[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -347,12 +364,12 @@ static inline bool ng_ipv6_addr_is_link_local(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is a site-local unicast address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_site_local(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_site_local(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (((byteorder_ntohs(addr->u16[0]) & 0xFFC0) ==
|
||||
NG_IPV6_ADDR_SITE_LOCAL_PREFIX) ||
|
||||
(ng_ipv6_addr_is_multicast(addr) &&
|
||||
(addr->u8[1] & 0x0f) == NG_IPV6_ADDR_MCAST_SCP_SITE_LOCAL));
|
||||
return (((byteorder_ntohs(addr->u16[0]) & 0xffc0) ==
|
||||
IPV6_ADDR_SITE_LOCAL_PREFIX) ||
|
||||
(ipv6_addr_is_multicast(addr) &&
|
||||
(addr->u8[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_SITE_LOCAL));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,7 +384,7 @@ static inline bool ng_ipv6_addr_is_site_local(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is unique local unicast address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_unique_local_unicast(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_unique_local_unicast(const ipv6_addr_t *addr)
|
||||
{
|
||||
return ((addr->u8[0] == 0xfc) || (addr->u8[0] == 0xfd));
|
||||
}
|
||||
@ -384,22 +401,22 @@ static inline bool ng_ipv6_addr_is_unique_local_unicast(const ng_ipv6_addr_t *ad
|
||||
* @return true, if @p addr is global unicast address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_global(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_global(const ipv6_addr_t *addr)
|
||||
{
|
||||
/* first check for multicast with global scope */
|
||||
if (ng_ipv6_addr_is_multicast(addr)) {
|
||||
return ((addr->u8[1] & 0x0f) == NG_IPV6_ADDR_MCAST_SCP_GLOBAL);
|
||||
if (ipv6_addr_is_multicast(addr)) {
|
||||
return ((addr->u8[1] & 0x0f) == IPV6_ADDR_MCAST_SCP_GLOBAL);
|
||||
}
|
||||
else {
|
||||
/* for unicast check if: */
|
||||
/* - not unspecific or loopback */
|
||||
return (!((addr->u64[0].u64 == 0) &&
|
||||
((byteorder_ntohll(addr->u64[1]) & (0xfffffffffffffffe)) == 0)) &&
|
||||
((byteorder_ntohll(addr->u64[1]) & (0xfffffffffffffffe)) == 0)) &&
|
||||
/* - not link-local */
|
||||
(byteorder_ntohll(addr->u64[0]) != 0xfe80000000000000) &&
|
||||
/* - not site-local */
|
||||
((byteorder_ntohs(addr->u16[0]) & 0xffc0) !=
|
||||
NG_IPV6_ADDR_SITE_LOCAL_PREFIX));
|
||||
IPV6_ADDR_SITE_LOCAL_PREFIX));
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,7 +433,7 @@ static inline bool ng_ipv6_addr_is_global(const ng_ipv6_addr_t *addr)
|
||||
* @return true, if @p addr is solicited-node multicast address,
|
||||
* @return false, otherwise.
|
||||
*/
|
||||
static inline bool ng_ipv6_addr_is_solicited_node(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ipv6_addr_is_solicited_node(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (byteorder_ntohll(addr->u64[0]) == 0xff02000000000000) &&
|
||||
(byteorder_ntohl(addr->u32[2]) == 1) &&
|
||||
@ -433,7 +450,7 @@ static inline bool ng_ipv6_addr_is_solicited_node(const ng_ipv6_addr_t *addr)
|
||||
*
|
||||
* @return The number of bits @p a and @p b match in their prefix
|
||||
*/
|
||||
uint8_t ng_ipv6_addr_match_prefix(const ng_ipv6_addr_t *a, const ng_ipv6_addr_t *b);
|
||||
uint8_t ipv6_addr_match_prefix(const ipv6_addr_t *a, const ipv6_addr_t *b);
|
||||
|
||||
/**
|
||||
* @brief Sets IPv6 address @p out with the first @p bits taken
|
||||
@ -444,8 +461,7 @@ uint8_t ng_ipv6_addr_match_prefix(const ng_ipv6_addr_t *a, const ng_ipv6_addr_t
|
||||
* @param[in] bits Bits to be copied from @p prefix to @p out
|
||||
* (set to 128 when greater than 128).
|
||||
*/
|
||||
void ng_ipv6_addr_init_prefix(ng_ipv6_addr_t *out, const ng_ipv6_addr_t *prefix,
|
||||
uint8_t bits);
|
||||
void ipv6_addr_init_prefix(ipv6_addr_t *out, const ipv6_addr_t *prefix, uint8_t bits);
|
||||
|
||||
/**
|
||||
* @brief Sets @p addr dynamically to the unspecified IPv6 address (::).
|
||||
@ -456,7 +472,7 @@ void ng_ipv6_addr_init_prefix(ng_ipv6_addr_t *out, const ng_ipv6_addr_t *prefix,
|
||||
*
|
||||
* @param[in,out] addr The address to set.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_unspecified(ng_ipv6_addr_t *addr)
|
||||
static inline void ipv6_addr_set_unspecified(ipv6_addr_t *addr)
|
||||
{
|
||||
addr->u64[0].u64 = 0;
|
||||
addr->u64[1].u64 = 0;
|
||||
@ -471,7 +487,7 @@ static inline void ng_ipv6_addr_set_unspecified(ng_ipv6_addr_t *addr)
|
||||
*
|
||||
* @param[in,out] addr The address to set.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_loopback(ng_ipv6_addr_t *addr)
|
||||
static inline void ipv6_addr_set_loopback(ipv6_addr_t *addr)
|
||||
{
|
||||
addr->u64[0].u64 = 0;
|
||||
addr->u64[1] = byteorder_htonll(1);
|
||||
@ -486,7 +502,7 @@ static inline void ng_ipv6_addr_set_loopback(ng_ipv6_addr_t *addr)
|
||||
*
|
||||
* @param[in,out] addr The address to set.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_link_local_prefix(ng_ipv6_addr_t *addr)
|
||||
static inline void ipv6_addr_set_link_local_prefix(ipv6_addr_t *addr)
|
||||
{
|
||||
addr->u64[0] = byteorder_htonll(0xfe80000000000000);
|
||||
}
|
||||
@ -502,7 +518,7 @@ static inline void ng_ipv6_addr_set_link_local_prefix(ng_ipv6_addr_t *addr)
|
||||
* @param[in,out] addr The address to set.
|
||||
* @param[in] iid The interface ID as integer to set.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_iid(ng_ipv6_addr_t *addr, uint64_t iid)
|
||||
static inline void ipv6_addr_set_iid(ipv6_addr_t *addr, uint64_t iid)
|
||||
{
|
||||
addr->u64[1] = byteorder_htonll(iid);
|
||||
}
|
||||
@ -518,7 +534,7 @@ static inline void ng_ipv6_addr_set_iid(ng_ipv6_addr_t *addr, uint64_t iid)
|
||||
* @param[in,out] addr The address to set.
|
||||
* @param[in] iid The interface ID as array of at least length 8 to set.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_aiid(ng_ipv6_addr_t *addr, uint8_t *iid)
|
||||
static inline void ipv6_addr_set_aiid(ipv6_addr_t *addr, uint8_t *iid)
|
||||
{
|
||||
addr->u8[8] = iid[0];
|
||||
addr->u8[9] = iid[1];
|
||||
@ -541,9 +557,8 @@ static inline void ng_ipv6_addr_set_aiid(ng_ipv6_addr_t *addr, uint8_t *iid)
|
||||
* @param[in] flags The multicast address' flags.
|
||||
* @param[in] scope The multicast address' scope.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_multicast(ng_ipv6_addr_t *addr,
|
||||
ng_ipv6_addr_mcast_flag_t flags,
|
||||
ng_ipv6_addr_mcast_scp_t scope)
|
||||
static inline void ipv6_addr_set_multicast(ipv6_addr_t *addr, unsigned int flags,
|
||||
unsigned int scope)
|
||||
{
|
||||
addr->u8[0] = 0xff;
|
||||
addr->u8[1] = (((uint8_t)flags) << 4) | (((uint8_t) scope) & 0x0f);
|
||||
@ -560,8 +575,7 @@ static inline void ng_ipv6_addr_set_multicast(ng_ipv6_addr_t *addr,
|
||||
* @param[in,out] addr The address to set.
|
||||
* @param[in] scope The multicast address' scope.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_all_nodes_multicast(ng_ipv6_addr_t *addr,
|
||||
ng_ipv6_addr_mcast_scp_t scope)
|
||||
static inline void ipv6_addr_set_all_nodes_multicast(ipv6_addr_t *addr, unsigned int scope)
|
||||
{
|
||||
addr->u64[0] = byteorder_htonll(0xff00000000000000);
|
||||
addr->u8[1] = (uint8_t)scope;
|
||||
@ -579,8 +593,7 @@ static inline void ng_ipv6_addr_set_all_nodes_multicast(ng_ipv6_addr_t *addr,
|
||||
* @param[in,out] addr The address to set.
|
||||
* @param[in] scope The multicast address' scope.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_all_routers_multicast(ng_ipv6_addr_t *addr,
|
||||
ng_ipv6_addr_mcast_scp_t scope)
|
||||
static inline void ipv6_addr_set_all_routers_multicast(ipv6_addr_t *addr, unsigned int scope)
|
||||
{
|
||||
addr->u64[0] = byteorder_htonll(0xff00000000000000);
|
||||
addr->u8[1] = (uint8_t)scope;
|
||||
@ -598,8 +611,7 @@ static inline void ng_ipv6_addr_set_all_routers_multicast(ng_ipv6_addr_t *addr,
|
||||
* @param[out] out Is set to solicited-node address of this node.
|
||||
* @param[in] in The IPv6 address the solicited-node address.
|
||||
*/
|
||||
static inline void ng_ipv6_addr_set_solicited_nodes(ng_ipv6_addr_t *out,
|
||||
const ng_ipv6_addr_t *in)
|
||||
static inline void ipv6_addr_set_solicited_nodes(ipv6_addr_t *out, const ipv6_addr_t *in)
|
||||
{
|
||||
out->u64[0] = byteorder_htonll(0xff02000000000000);
|
||||
out->u32[2] = byteorder_htonl(1);
|
||||
@ -623,8 +635,7 @@ static inline void ng_ipv6_addr_set_solicited_nodes(ng_ipv6_addr_t *out,
|
||||
* @return NULL, if @p result_len was smaller than needed
|
||||
* @return NULL, if @p result or @p addr was NULL
|
||||
*/
|
||||
char *ng_ipv6_addr_to_str(char *result, const ng_ipv6_addr_t *addr,
|
||||
uint8_t result_len);
|
||||
char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len);
|
||||
|
||||
/**
|
||||
* @brief Converts an IPv6 address string representation to a byte-represented
|
||||
@ -641,13 +652,13 @@ char *ng_ipv6_addr_to_str(char *result, const ng_ipv6_addr_t *addr,
|
||||
* @return NULL, if @p addr was malformed
|
||||
* @return NULL, if @p result or @p addr was NULL
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr);
|
||||
ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NG_IPV6_ADDR_H_ */
|
||||
#endif /* IPV6_ADDR_H_ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
@ -32,7 +32,7 @@
|
||||
#include "net/ng_netbase.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6.h"
|
||||
#include "net/ng_ipv6/ext.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef NG_IPV6_EXT_RH_H_
|
||||
#define NG_IPV6_EXT_RH_H_
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -51,7 +51,7 @@ typedef struct __attribute__((packed)) {
|
||||
* @return next hop on success, on success
|
||||
* @return NULL, if not found.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_ext_rh_next_hop(ng_ipv6_hdr_t *ipv6);
|
||||
ipv6_addr_t *ng_ipv6_ext_rh_next_hop(ng_ipv6_hdr_t *ipv6);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/inet_csum.h"
|
||||
#include "net/ng_pkt.h"
|
||||
|
||||
@ -92,8 +92,8 @@ typedef struct __attribute__((packed)) {
|
||||
network_uint16_t len; /**< payload length of this packet. */
|
||||
uint8_t nh; /**< type of next header in this packet. */
|
||||
uint8_t hl; /**< hop limit for this packet. */
|
||||
ng_ipv6_addr_t src; /**< source address of this packet. */
|
||||
ng_ipv6_addr_t dst; /**< destination address of this packet. */
|
||||
ipv6_addr_t src; /**< source address of this packet. */
|
||||
ipv6_addr_t dst; /**< destination address of this packet. */
|
||||
} ng_ipv6_hdr_t;
|
||||
|
||||
/**
|
||||
@ -295,7 +295,7 @@ static inline uint16_t ng_ipv6_hdr_inet_csum(uint16_t sum, ng_ipv6_hdr_t *hdr,
|
||||
}
|
||||
|
||||
return inet_csum(sum + len + prot_num, hdr->src.u8,
|
||||
(2 * sizeof(ng_ipv6_addr_t)));
|
||||
(2 * sizeof(ipv6_addr_t)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,11 +308,11 @@ static inline uint16_t ng_ipv6_hdr_inet_csum(uint16_t sum, ng_ipv6_hdr_t *hdr,
|
||||
* @param[in] src Source address for the header. Can be NULL if not
|
||||
* known or required.
|
||||
* @param[in] src_len Length of @p src. Can be 0 if not known or required or
|
||||
* must be `sizeof(ng_ipv6_addr_t)`.
|
||||
* must be `sizeof(ipv6_addr_t)`.
|
||||
* @param[in] dst Destination address for the header. Can be NULL if not
|
||||
* known or required.
|
||||
* @param[in] dst_len Length of @p dst. Can be 0 if not known or required or
|
||||
* must be `sizeof(ng_ipv6_addr_t)`.
|
||||
* must be `sizeof(ipv6_addr_t)`.
|
||||
*
|
||||
* @return The an IPv6 header in packet buffer on success.
|
||||
* @return NULL on error.
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/ng_pktqueue.h"
|
||||
#include "vtimer.h"
|
||||
@ -119,7 +119,7 @@ extern "C" {
|
||||
*/
|
||||
typedef struct {
|
||||
ng_pktqueue_t *pkts; /**< Packets waiting for address resolution */
|
||||
ng_ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
|
||||
ipv6_addr_t ipv6_addr; /**< IPv6 address of the neighbor */
|
||||
uint8_t l2_addr[NG_IPV6_NC_L2_ADDR_MAX];/**< Link layer address of the neighbor */
|
||||
uint8_t l2_addr_len; /**< Length of ng_ipv6_nc_t::l2_addr */
|
||||
uint8_t flags; /**< Flags as defined above */
|
||||
@ -167,7 +167,7 @@ void ng_ipv6_nc_init(void);
|
||||
* @return Pointer to new neighbor cache entry on success
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr,
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr,
|
||||
const void *l2_addr, size_t l2_addr_len, uint8_t flags);
|
||||
|
||||
/**
|
||||
@ -178,7 +178,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
* interfaces.
|
||||
* @param[in] ipv6_addr IPv6 address of the neighbor
|
||||
*/
|
||||
void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr);
|
||||
void ng_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for any neighbor cache entry fitting the @p ipv6_addr.
|
||||
@ -191,7 +191,7 @@ void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr);
|
||||
* @return The neighbor cache entry, if one is found.
|
||||
* @return NULL, if none is found.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr);
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
/**
|
||||
* @brief Gets next entry in neighbor cache after @p prev.
|
||||
@ -273,7 +273,7 @@ static inline bool ng_ipv6_nc_is_reachable(const ng_ipv6_nc_t *entry)
|
||||
* @return The neighbor cache entry, if one is found.
|
||||
* @return NULL, if none is found.
|
||||
*/
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ng_ipv6_addr_t *ipv6_addr);
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "kernel_macros.h"
|
||||
#include "kernel_types.h"
|
||||
#include "mutex.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "vtimer.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -153,7 +153,7 @@ extern "C" {
|
||||
* @brief Type to represent an IPv6 address registered to an interface.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_ipv6_addr_t addr; /**< The address data */
|
||||
ipv6_addr_t addr; /**< The address data */
|
||||
uint8_t flags; /**< flags */
|
||||
uint8_t prefix_len; /**< length of the prefix of the address */
|
||||
/**
|
||||
@ -290,10 +290,9 @@ static inline void ng_ipv6_netif_set_rtr_adv(ng_ipv6_netif_t *netif, bool enable
|
||||
*
|
||||
* @param[in] netif The interface.
|
||||
* @param[in] dst The address of the neighboring router.
|
||||
* May be NULL for @ref NG_IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL.
|
||||
* May be NULL for @ref IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL.
|
||||
*/
|
||||
static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif,
|
||||
ng_ipv6_addr_t *dst)
|
||||
static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif, ipv6_addr_t *dst)
|
||||
{
|
||||
(void)netif; /* TODO */
|
||||
(void)dst;
|
||||
@ -321,8 +320,8 @@ static inline void ng_ipv6_netif_sol_router(ng_ipv6_netif_t *netif,
|
||||
* @return The address on the interface, on success.
|
||||
* @return NULL, on failure
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *addr,
|
||||
uint8_t prefix_len, uint8_t flags);
|
||||
ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr, uint8_t prefix_len,
|
||||
uint8_t flags);
|
||||
|
||||
/**
|
||||
* @brief Remove an address from the interface.
|
||||
@ -331,7 +330,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *a
|
||||
* it will be removed from all interfaces.
|
||||
* @param[in] addr An address you want to remove from interface.
|
||||
*/
|
||||
void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ng_ipv6_addr_t *addr);
|
||||
void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Removes all addresses from the interface.
|
||||
@ -349,8 +348,7 @@ void ng_ipv6_netif_reset_addr(kernel_pid_t pid);
|
||||
* @return The PID to the interface the address is registered to.
|
||||
* @return KERNEL_PID_UNDEF, if the address can not be found on any interface.
|
||||
*/
|
||||
kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out,
|
||||
const ng_ipv6_addr_t *addr);
|
||||
kernel_pid_t ng_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for an address on an interface.
|
||||
@ -362,8 +360,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out,
|
||||
* @return NULL, if the address can not be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid,
|
||||
const ng_ipv6_addr_t *addr);
|
||||
ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Searches for the first address matching a prefix best on all
|
||||
@ -376,8 +373,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid,
|
||||
* @return KERNEL_PID_UNDEF, if no matching address can not be found on any
|
||||
* interface.
|
||||
*/
|
||||
kernel_pid_t ng_ipv6_netif_find_by_prefix(ng_ipv6_addr_t **out,
|
||||
const ng_ipv6_addr_t *prefix);
|
||||
kernel_pid_t ng_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *prefix);
|
||||
|
||||
/**
|
||||
* @brief Searches for the first address matching a prefix best on an
|
||||
@ -390,8 +386,7 @@ kernel_pid_t ng_ipv6_netif_find_by_prefix(ng_ipv6_addr_t **out,
|
||||
* @return NULL, if no matching address can be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid,
|
||||
const ng_ipv6_addr_t *prefix);
|
||||
ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *prefix);
|
||||
|
||||
/**
|
||||
* @brief Searches for the best address on an interface usable as a
|
||||
@ -405,7 +400,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid,
|
||||
* @return NULL, if no matching address can be found on the interface.
|
||||
* @return NULL, if @p pid is no interface.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ng_ipv6_addr_t *dest);
|
||||
ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dest);
|
||||
|
||||
/**
|
||||
* @brief Get interface specific meta-information on an address
|
||||
@ -426,7 +421,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ng_ipv6
|
||||
*
|
||||
* @return Interface specific meta-information on @p addr
|
||||
*/
|
||||
static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ng_ipv6_addr_t *addr)
|
||||
static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ipv6_addr_t *addr)
|
||||
{
|
||||
return container_of(addr, ng_ipv6_netif_addr_t, addr);
|
||||
}
|
||||
@ -451,7 +446,7 @@ static inline ng_ipv6_netif_addr_t *ng_ipv6_netif_addr_get(const ng_ipv6_addr_t
|
||||
* @return true, if address is anycast or multicast.
|
||||
* @return false, if address is unicast.
|
||||
*/
|
||||
static inline bool ng_ipv6_netif_addr_is_non_unicast(const ng_ipv6_addr_t *addr)
|
||||
static inline bool ng_ipv6_netif_addr_is_non_unicast(const ipv6_addr_t *addr)
|
||||
{
|
||||
return (bool)(container_of(addr, ng_ipv6_netif_addr_t, addr)->flags &
|
||||
NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "byteorder.h"
|
||||
#include "net/ng_pkt.h"
|
||||
#include "net/ng_icmpv6.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
|
||||
@ -181,7 +181,7 @@ void ng_ndp_netif_remove(ng_ipv6_netif_t *iface);
|
||||
* @return The resulting ICMPv6 packet on success.
|
||||
* @return NULL, on failure.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_nbr_sol_build(ng_ipv6_addr_t *tgt, ng_pktsnip_t *options);
|
||||
ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options);
|
||||
|
||||
/**
|
||||
* @brief Builds a neighbor advertisement message for sending.
|
||||
@ -209,7 +209,7 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ng_ipv6_addr_t *tgt, ng_pktsnip_t *options);
|
||||
* @return The resulting ICMPv6 packet on success.
|
||||
* @return NULL, on failure.
|
||||
*/
|
||||
ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ng_ipv6_addr_t *tgt,
|
||||
ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
|
||||
ng_pktsnip_t *options);
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifndef INTERNAL_H_
|
||||
#define INTERNAL_H_
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ndp/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -41,7 +41,7 @@ extern "C" {
|
||||
* @return Address to a default router.
|
||||
* @return NULL, if the default router list is empty.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_ndp_internal_default_router(void);
|
||||
ipv6_addr_t *ng_ndp_internal_default_router(void);
|
||||
|
||||
/**
|
||||
* @brief Sets state of a neighbor cache entry and triggers required actions.
|
||||
@ -64,8 +64,8 @@ void ng_ndp_internal_set_state(ng_ipv6_nc_t *nc_entry, uint8_t state);
|
||||
* @param[in] dst Destination address for neighbor solicitation. May not be
|
||||
* NULL.
|
||||
*/
|
||||
void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
ng_ipv6_addr_t *dst);
|
||||
void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst);
|
||||
|
||||
/**
|
||||
* @brief Send precompiled neighbor advertisement.
|
||||
@ -80,8 +80,8 @@ void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
* @param[in] supply_tl2a Add target link-layer address option to neighbor
|
||||
* advertisement if link-layer has addresses.
|
||||
*/
|
||||
void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
ng_ipv6_addr_t *dst, bool supply_tl2a);
|
||||
void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst, bool supply_tl2a);
|
||||
|
||||
/**
|
||||
* @brief Handles a SL2A option.
|
||||
|
@ -42,7 +42,7 @@ extern "C" {
|
||||
* would be long.
|
||||
*/
|
||||
kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ng_ipv6_addr_t *dst,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
ng_pktsnip_t *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -142,7 +142,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t code; /**< message code */
|
||||
network_uint16_t csum; /**< checksum */
|
||||
network_uint32_t resv; /**< reserved field */
|
||||
ng_ipv6_addr_t tgt; /**< target address */
|
||||
ipv6_addr_t tgt; /**< target address */
|
||||
} ng_ndp_nbr_sol_t;
|
||||
|
||||
/**
|
||||
@ -159,7 +159,7 @@ typedef struct __attribute__((packed)) {
|
||||
network_uint16_t csum; /**< checksum */
|
||||
uint8_t flags; /**< flags */
|
||||
uint8_t resv[3]; /**< reserved fields */
|
||||
ng_ipv6_addr_t tgt; /**< target address */
|
||||
ipv6_addr_t tgt; /**< target address */
|
||||
} ng_ndp_nbr_adv_t;
|
||||
|
||||
/**
|
||||
@ -175,8 +175,8 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t code; /**< message code */
|
||||
network_uint16_t csum; /**< checksum */
|
||||
network_uint32_t resv; /**< reserved field */
|
||||
ng_ipv6_addr_t tgt; /**< target address */
|
||||
ng_ipv6_addr_t dst; /**< destination address */
|
||||
ipv6_addr_t tgt; /**< target address */
|
||||
ipv6_addr_t dst; /**< destination address */
|
||||
} ng_ndp_redirect_t;
|
||||
|
||||
/**
|
||||
@ -209,7 +209,7 @@ typedef struct __attribute__((packed)) {
|
||||
network_uint32_t valid_ltime; /**< valid lifetime */
|
||||
network_uint32_t pref_ltime; /**< preferred lifetime */
|
||||
network_uint32_t resv; /**< reserved field */
|
||||
ng_ipv6_addr_t prefix; /**< prefix */
|
||||
ipv6_addr_t prefix; /**< prefix */
|
||||
} ng_ndp_opt_pi_t;
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@
|
||||
#ifndef NG_RPL_SRH_H_
|
||||
#define NG_RPL_SRH_H_
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/ext.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -59,7 +59,7 @@ typedef struct __attribute__((packed)) {
|
||||
* @return next hop, on success
|
||||
* @return NULL, if not found.
|
||||
*/
|
||||
ng_ipv6_addr_t *ng_rpl_srh_next_hop(ng_rpl_srh_t *rh);
|
||||
ipv6_addr_t *ng_rpl_srh_next_hop(ng_rpl_srh_t *rh);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <inttypes.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -56,7 +56,7 @@ extern "C" {
|
||||
* @brief Entry in the 6LoWPAN context buffer.
|
||||
*/
|
||||
typedef struct {
|
||||
ng_ipv6_addr_t prefix; /**< The prefix associated to this context. */
|
||||
ipv6_addr_t prefix; /**< The prefix associated to this context. */
|
||||
uint8_t prefix_len; /**< Length of ng_sixlowpan_ctx_t::prefix in bit. */
|
||||
/**
|
||||
* @brief 4-bit flags, 4-bit Context ID.
|
||||
@ -85,7 +85,7 @@ typedef struct {
|
||||
* @return The context associated with the best prefix for @p addr.
|
||||
* @return NULL if there is no such context.
|
||||
*/
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ng_ipv6_addr_t *addr);
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr);
|
||||
|
||||
/**
|
||||
* @brief Gets context by ID.
|
||||
@ -112,7 +112,7 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_id(uint8_t id);
|
||||
* @return The new context on success.
|
||||
* @return NULL, on error or on removal.
|
||||
*/
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ng_ipv6_addr_t *prefix,
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *prefix,
|
||||
uint8_t prefix_len, uint16_t ltime,
|
||||
bool comp);
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "thread.h"
|
||||
|
||||
@ -198,7 +198,7 @@ typedef struct {
|
||||
le_uint16_t pan; /**< the device's PAN ID */
|
||||
uint16_t flags; /**< the device's option flags */
|
||||
uint32_t seq; /**< the current sequence number for frames */
|
||||
ng_ipv6_addr_t dst; /**< destination IPv6 address */
|
||||
ipv6_addr_t dst; /**< destination IPv6 address */
|
||||
uint16_t src_port; /**< source UDP port */
|
||||
uint16_t dst_port; /**< destination UDP port */
|
||||
ng_nettype_t proto; /**< the target protocol for received packets */
|
||||
@ -229,7 +229,7 @@ typedef struct {
|
||||
* @return -ENOTSUP, if @p dst is NULL or unspecified address (::).
|
||||
* @return -EOVERFLOW, if there are too many threads running already
|
||||
*/
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ng_ipv6_addr_t *dst,
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -113,7 +113,7 @@ int universal_address_compare(universal_address_container_t *entry,
|
||||
* @param[in] prefix pointer to the address for compare
|
||||
* @param[in] prefix_size_in_bits the number of bits used for the prefix entry.
|
||||
* This size MUST be the full address size including trailing '0's,
|
||||
* e.g. for an ng_ipv6_addr_t it would be sizeof(ng_ipv6_addr_t)
|
||||
* e.g. for an ipv6_addr_t it would be sizeof(ipv6_addr_t)
|
||||
* regardless if the stored prefix is < ::/128
|
||||
*
|
||||
* @return 0 if the entries are equal
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "kernel.h"
|
||||
#include "msg.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_netbase.h"
|
||||
#include "net/ng_udp.h"
|
||||
@ -89,7 +89,7 @@ static size_t _get_frame_hdr_len(uint8_t *mhr);
|
||||
ng_pktsnip_t *_make_netif_hdr(uint8_t *mhr);
|
||||
static uint16_t _calc_fcs(uint16_t fcs, const uint8_t *frame, uint8_t frame_len);
|
||||
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ng_ipv6_addr_t *dst,
|
||||
kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ipv6_addr_t *dst,
|
||||
uint16_t dst_port)
|
||||
{
|
||||
#if CPUID_ID_LEN
|
||||
@ -107,7 +107,7 @@ kernel_pid_t ng_zep_init(ng_zep_t *dev, uint16_t src_port, ng_ipv6_addr_t *dst,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if ((dst == NULL) || (ng_ipv6_addr_is_unspecified(dst))) {
|
||||
if ((dst == NULL) || (ipv6_addr_is_unspecified(dst))) {
|
||||
DEBUG("zep: dst (%s) was NULL or unspecified\n", dst);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
@ -250,7 +250,7 @@ static int _send(ng_netdev_t *netdev, ng_pktsnip_t *pkt)
|
||||
new_pkt = hdr;
|
||||
|
||||
hdr = ng_ipv6_hdr_build(new_pkt, NULL, 0, (uint8_t *) &(dev->dst),
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
if (hdr == NULL) {
|
||||
DEBUG("zep: could not allocate IPv6 header in pktbuf\n");
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "kernel.h"
|
||||
#include "net/ng_pktdump.h"
|
||||
#include "net/ng_netbase.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_sixlowpan.h"
|
||||
#include "net/ng_udp.h"
|
||||
|
@ -182,7 +182,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint8_t sin6_family; ///< set to AF_INET6
|
||||
uint16_t sin6_port; ///< transport layer port number
|
||||
uint32_t sin6_flowinfo; ///< IPv6 flow information
|
||||
ng_ipv6_addr_t sin6_addr; ///< IPv6 address
|
||||
ipv6_addr_t sin6_addr; ///< IPv6 address
|
||||
} sockaddr6_t;
|
||||
|
||||
/**
|
||||
|
@ -33,12 +33,12 @@
|
||||
#include "net/fib.h"
|
||||
#include "net/fib/table.h"
|
||||
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
#include "net/ipv6/addr.h"
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
#define NG_FIB_ADDR_PRINT_LEN 39
|
||||
#else
|
||||
#define NG_FIB_ADDR_PRINT_LEN 32
|
||||
@ -646,10 +646,10 @@ static void fib_print_address(universal_address_container_t *entry)
|
||||
uint8_t *ret = universal_address_get_address(entry, address, &addr_size);
|
||||
|
||||
if (ret == address) {
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
if (addr_size == sizeof(ng_ipv6_addr_t)) {
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
if (addr_size == sizeof(ipv6_addr_t)) {
|
||||
printf("%-" NG_FIB_ADDR_PRINT_LENS "s",
|
||||
ng_ipv6_addr_to_str(addr_str, (ng_ipv6_addr_t *) address, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, (ipv6_addr_t *) address, sizeof(addr_str)));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -661,7 +661,7 @@ static void fib_print_address(universal_address_container_t *entry)
|
||||
printf(" ");
|
||||
}
|
||||
}
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
/* print trailing whitespaces */
|
||||
for (size_t i = 0; i < NG_FIB_ADDR_PRINT_LEN - (UNIVERSAL_ADDRESS_SIZE * 2); ++i) {
|
||||
printf(" ");
|
||||
|
@ -1,3 +1,3 @@
|
||||
MODULE = ng_ipv6_addr
|
||||
MODULE = ipv6_addr
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -17,9 +17,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
uint8_t ng_ipv6_addr_match_prefix(const ng_ipv6_addr_t *a, const ng_ipv6_addr_t *b)
|
||||
uint8_t ipv6_addr_match_prefix(const ipv6_addr_t *a, const ipv6_addr_t *b)
|
||||
{
|
||||
uint8_t prefix_len = 0;
|
||||
|
||||
@ -57,8 +57,8 @@ uint8_t ng_ipv6_addr_match_prefix(const ng_ipv6_addr_t *a, const ng_ipv6_addr_t
|
||||
return prefix_len;
|
||||
}
|
||||
|
||||
void ng_ipv6_addr_init_prefix(ng_ipv6_addr_t *out, const ng_ipv6_addr_t *prefix,
|
||||
uint8_t bits)
|
||||
void ipv6_addr_init_prefix(ipv6_addr_t *out, const ipv6_addr_t *prefix,
|
||||
uint8_t bits)
|
||||
{
|
||||
uint8_t bytes;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
#define DEC "0123456789"
|
||||
#define HEX_L "0123456789abcdef"
|
||||
@ -91,7 +91,7 @@ static network_uint32_t *ipv4_addr_from_str(network_uint32_t *result,
|
||||
}
|
||||
|
||||
/* based on inet_pton6() by Paul Vixie */
|
||||
ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
ipv6_addr_t *ipv6_addr_from_str(ipv6_addr_t *result, const char *addr)
|
||||
{
|
||||
uint8_t *colonp = 0;
|
||||
const char *curtok = addr;
|
||||
@ -104,7 +104,7 @@ ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_set_unspecified(result);
|
||||
ipv6_addr_set_unspecified(result);
|
||||
|
||||
/* Leading :: requires some special handling. */
|
||||
if (*addr == ':') {
|
||||
@ -145,7 +145,7 @@ ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > sizeof(ng_ipv6_addr_t)) {
|
||||
if (i > sizeof(ipv6_addr_t)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '.' && (i <= sizeof(ng_ipv6_addr_t)) &&
|
||||
if (ch == '.' && (i <= sizeof(ipv6_addr_t)) &&
|
||||
ipv4_addr_from_str((network_uint32_t *)(&(result->u8[i])),
|
||||
curtok) != NULL) {
|
||||
i += sizeof(network_uint32_t);
|
||||
@ -168,7 +168,7 @@ ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
}
|
||||
|
||||
if (saw_xdigit) {
|
||||
if (i + sizeof(uint16_t) > sizeof(ng_ipv6_addr_t)) {
|
||||
if (i + sizeof(uint16_t) > sizeof(ipv6_addr_t)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -184,14 +184,14 @@ ng_ipv6_addr_t *ng_ipv6_addr_from_str(ng_ipv6_addr_t *result, const char *addr)
|
||||
const int32_t n = &(result->u8[i++]) - colonp;
|
||||
|
||||
for (int32_t j = 1; j <= n; j++) {
|
||||
result->u8[sizeof(ng_ipv6_addr_t) - j] = colonp[n - j];
|
||||
result->u8[sizeof(ipv6_addr_t) - j] = colonp[n - j];
|
||||
colonp[n - j] = 0;
|
||||
}
|
||||
|
||||
i = sizeof(ng_ipv6_addr_t);
|
||||
i = sizeof(ipv6_addr_t);
|
||||
}
|
||||
|
||||
if (i != sizeof(ng_ipv6_addr_t)) {
|
||||
if (i != sizeof(ipv6_addr_t)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -30,10 +30,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
/* Length of an IPv6 address in 16-bit words */
|
||||
#define IPV6_ADDR_WORD_LEN (sizeof(ng_ipv6_addr_t) / sizeof(uint16_t))
|
||||
#define IPV6_ADDR_WORD_LEN (sizeof(ipv6_addr_t) / sizeof(uint16_t))
|
||||
|
||||
#define IPV4_ADDR_MIN_STR_LEN (sizeof("255.255.255.255"))
|
||||
|
||||
@ -75,10 +75,9 @@ static char *ipv4_addr_to_str(char *result, const network_uint32_t *addr,
|
||||
}
|
||||
|
||||
/* based on inet_ntop6() by Paul Vixie */
|
||||
char *ng_ipv6_addr_to_str(char *result, const ng_ipv6_addr_t *addr,
|
||||
uint8_t result_len)
|
||||
char *ipv6_addr_to_str(char *result, const ipv6_addr_t *addr, uint8_t result_len)
|
||||
{
|
||||
char tmp[NG_IPV6_ADDR_MAX_STR_LEN], *tp;
|
||||
char tmp[IPV6_ADDR_MAX_STR_LEN], *tp;
|
||||
struct {
|
||||
int16_t base, len;
|
||||
} best = { -1, 0}, cur = { -1, 0};
|
@ -82,14 +82,14 @@ void ng_icmpv6_echo_req_handle(kernel_pid_t iface, ng_ipv6_hdr_t *ipv6_hdr,
|
||||
return;
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
|
||||
if (ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
|
||||
hdr = ng_ipv6_hdr_build(pkt, NULL, 0, (uint8_t *)&ipv6_hdr->src,
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
}
|
||||
else {
|
||||
hdr = ng_ipv6_hdr_build(pkt, (uint8_t *)&ipv6_hdr->dst,
|
||||
sizeof(ng_ipv6_addr_t), (uint8_t *)&ipv6_hdr->src,
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t), (uint8_t *)&ipv6_hdr->src,
|
||||
sizeof(ipv6_addr_t));
|
||||
}
|
||||
|
||||
if (hdr == NULL) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "net/ng_rpl/srh.h"
|
||||
#include "net/ng_ipv6/ext/rh.h"
|
||||
|
||||
ng_ipv6_addr_t *ng_ipv6_ext_rh_next_hop(ng_ipv6_hdr_t *ipv6)
|
||||
ipv6_addr_t *ng_ipv6_ext_rh_next_hop(ng_ipv6_hdr_t *ipv6)
|
||||
{
|
||||
ng_ipv6_ext_rh_t *ext = (ng_ipv6_ext_rh_t *)(ipv6 + 1);
|
||||
bool c = true;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @file
|
||||
*/
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_nettype.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
@ -21,8 +21,8 @@
|
||||
#define ENABLE_DEBUG (0)
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG && defined(MODULE_NG_IPV6_ADDR)
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
#if ENABLE_DEBUG && defined(MODULE_IPV6_ADDR)
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
/* For independent testing */
|
||||
@ -39,10 +39,10 @@ ng_pktsnip_t *ng_ipv6_hdr_build(ng_pktsnip_t *payload,
|
||||
ng_pktsnip_t *ipv6;
|
||||
ng_ipv6_hdr_t *hdr;
|
||||
|
||||
if (((src_len != 0) && (src_len != sizeof(ng_ipv6_addr_t))) ||
|
||||
((dst_len != 0) && (dst_len != sizeof(ng_ipv6_addr_t)))) {
|
||||
if (((src_len != 0) && (src_len != sizeof(ipv6_addr_t))) ||
|
||||
((dst_len != 0) && (dst_len != sizeof(ipv6_addr_t)))) {
|
||||
DEBUG("ipv6_hdr: Address length was not 0 or %zu byte.\n",
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -56,31 +56,31 @@ ng_pktsnip_t *ng_ipv6_hdr_build(ng_pktsnip_t *payload,
|
||||
hdr = (ng_ipv6_hdr_t *)ipv6->data;
|
||||
|
||||
if ((src != NULL) && (src_len != 0)) {
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
DEBUG("ipv6_hdr: set packet source to %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, (ng_ipv6_addr_t *)src,
|
||||
sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, (ipv6_addr_t *)src,
|
||||
sizeof(addr_str)));
|
||||
#endif
|
||||
memcpy(&hdr->src, src, src_len);
|
||||
}
|
||||
else {
|
||||
DEBUG("ipv6_hdr: set packet source to ::\n");
|
||||
ng_ipv6_addr_set_unspecified(&hdr->src);
|
||||
ipv6_addr_set_unspecified(&hdr->src);
|
||||
}
|
||||
|
||||
memset(&hdr->dst + dst_len, 0, sizeof(ng_ipv6_addr_t) - dst_len);
|
||||
memset(&hdr->dst + dst_len, 0, sizeof(ipv6_addr_t) - dst_len);
|
||||
|
||||
if ((dst != NULL) && (dst_len != 0)) {
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
DEBUG("ipv6_hdr: set packet destination to %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, (ng_ipv6_addr_t *)dst,
|
||||
sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, (ipv6_addr_t *)dst,
|
||||
sizeof(addr_str)));
|
||||
#endif
|
||||
memcpy(&hdr->dst, dst, dst_len);
|
||||
}
|
||||
else {
|
||||
DEBUG("ipv6_hdr: set packet destination to ::1\n");
|
||||
ng_ipv6_addr_set_loopback(&hdr->dst);
|
||||
ipv6_addr_set_loopback(&hdr->dst);
|
||||
}
|
||||
|
||||
hdr->v_tc_fl = byteorder_htonl(0x60000000); /* set version, tc and fl in one go*/
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
void ng_ipv6_hdr_print(ng_ipv6_hdr_t *hdr)
|
||||
{
|
||||
char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
|
||||
if (!ng_ipv6_hdr_is(hdr)) {
|
||||
printf("illegal version field: %" PRIu8 "\n", ng_ipv6_hdr_get_version(hdr));
|
||||
@ -31,9 +31,9 @@ void ng_ipv6_hdr_print(ng_ipv6_hdr_t *hdr)
|
||||
printf("flow label: 0x%05" PRIx32 "\n", ng_ipv6_hdr_get_fl(hdr));
|
||||
printf("length: %" PRIu16 " next header: %" PRIu8 " hop limit: %" PRIu8 "\n",
|
||||
byteorder_ntohs(hdr->len), hdr->nh, hdr->hl);
|
||||
printf("source address: %s\n", ng_ipv6_addr_to_str(addr_str, &hdr->src,
|
||||
printf("source address: %s\n", ipv6_addr_to_str(addr_str, &hdr->src,
|
||||
sizeof(addr_str)));
|
||||
printf("destination address: %s\n", ng_ipv6_addr_to_str(addr_str, &hdr->dst,
|
||||
printf("destination address: %s\n", ipv6_addr_to_str(addr_str, &hdr->dst,
|
||||
sizeof(addr_str)));
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "net/ng_ipv6.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#include "net/ng_ndp.h"
|
||||
@ -32,7 +32,7 @@
|
||||
/* For PRIu8 etc. */
|
||||
#include <inttypes.h>
|
||||
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
static ng_ipv6_nc_t ncache[NG_IPV6_NC_SIZE];
|
||||
@ -45,7 +45,7 @@ void ng_ipv6_nc_init(void)
|
||||
ng_ipv6_nc_t *_find_free_entry(void)
|
||||
{
|
||||
for (int i = 0; i < NG_IPV6_NC_SIZE; i++) {
|
||||
if (ng_ipv6_addr_is_unspecified(&(ncache[i].ipv6_addr))) {
|
||||
if (ipv6_addr_is_unspecified(&(ncache[i].ipv6_addr))) {
|
||||
return ncache + i;
|
||||
}
|
||||
}
|
||||
@ -53,7 +53,7 @@ ng_ipv6_nc_t *_find_free_entry(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr,
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr,
|
||||
const void *l2_addr, size_t l2_addr_len, uint8_t flags)
|
||||
{
|
||||
ng_ipv6_nc_t *free_entry = NULL;
|
||||
@ -63,15 +63,15 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((l2_addr_len > NG_IPV6_NC_L2_ADDR_MAX) || ng_ipv6_addr_is_unspecified(ipv6_addr)) {
|
||||
if ((l2_addr_len > NG_IPV6_NC_L2_ADDR_MAX) || ipv6_addr_is_unspecified(ipv6_addr)) {
|
||||
DEBUG("ipv6_nc: invalid parameters\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NC_SIZE; i++) {
|
||||
if (ng_ipv6_addr_equal(&(ncache[i].ipv6_addr), ipv6_addr)) {
|
||||
if (ipv6_addr_equal(&(ncache[i].ipv6_addr), ipv6_addr)) {
|
||||
DEBUG("ipv6_nc: Address %s already registered.\n",
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
|
||||
if ((l2_addr != NULL) && (l2_addr_len > 0)) {
|
||||
DEBUG("ipv6_nc: Update to L2 address %s",
|
||||
@ -87,7 +87,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
return &ncache[i];
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_unspecified(&(ncache[i].ipv6_addr)) && !free_entry) {
|
||||
if (ipv6_addr_is_unspecified(&(ncache[i].ipv6_addr)) && !free_entry) {
|
||||
/* found the first free entry */
|
||||
free_entry = &ncache[i];
|
||||
}
|
||||
@ -103,9 +103,9 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
free_entry->iface = iface;
|
||||
|
||||
free_entry->pkts = NULL;
|
||||
memcpy(&(free_entry->ipv6_addr), ipv6_addr, sizeof(ng_ipv6_addr_t));
|
||||
memcpy(&(free_entry->ipv6_addr), ipv6_addr, sizeof(ipv6_addr_t));
|
||||
DEBUG("ipv6_nc: Register %s for interface %" PRIkernel_pid,
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
iface);
|
||||
|
||||
if ((l2_addr != NULL) && (l2_addr_len > 0)) {
|
||||
@ -128,13 +128,13 @@ ng_ipv6_nc_t *ng_ipv6_nc_add(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
return free_entry;
|
||||
}
|
||||
|
||||
void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr)
|
||||
void ng_ipv6_nc_remove(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr)
|
||||
{
|
||||
ng_ipv6_nc_t *entry = ng_ipv6_nc_get(iface, ipv6_addr);
|
||||
|
||||
if (entry != NULL) {
|
||||
DEBUG("ipv6_nc: Remove %s for interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
iface);
|
||||
|
||||
while (entry->pkts != NULL) {
|
||||
@ -145,13 +145,13 @@ void ng_ipv6_nc_remove(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr)
|
||||
ng_pktqueue_remove_head(&entry->pkts);
|
||||
}
|
||||
|
||||
ng_ipv6_addr_set_unspecified(&(entry->ipv6_addr));
|
||||
ipv6_addr_set_unspecified(&(entry->ipv6_addr));
|
||||
entry->iface = KERNEL_PID_UNDEF;
|
||||
entry->flags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr)
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ipv6_addr_t *ipv6_addr)
|
||||
{
|
||||
if (ipv6_addr == NULL) {
|
||||
DEBUG("ipv6_nc: address was NULL\n");
|
||||
@ -160,10 +160,10 @@ ng_ipv6_nc_t *ng_ipv6_nc_get(kernel_pid_t iface, const ng_ipv6_addr_t *ipv6_addr
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NC_SIZE; i++) {
|
||||
if (((iface == KERNEL_PID_UNDEF) || (iface == ncache[i].iface)) &&
|
||||
ng_ipv6_addr_equal(&(ncache[i].ipv6_addr), ipv6_addr)) {
|
||||
ipv6_addr_equal(&(ncache[i].ipv6_addr), ipv6_addr)) {
|
||||
DEBUG("ipv6_nc: Found entry for %s on interface %" PRIkernel_pid
|
||||
" (0 = all interfaces) [%p]\n",
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)),
|
||||
iface, (void *)(ncache + i));
|
||||
|
||||
return ncache + i;
|
||||
@ -183,7 +183,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_next(ng_ipv6_nc_t *prev)
|
||||
}
|
||||
|
||||
while (prev < (ncache + NG_IPV6_NC_SIZE)) { /* while not reached end */
|
||||
if (!ng_ipv6_addr_is_unspecified(&(prev->ipv6_addr))) {
|
||||
if (!ipv6_addr_is_unspecified(&(prev->ipv6_addr))) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
@ -205,13 +205,13 @@ ng_ipv6_nc_t *ng_ipv6_nc_get_next_router(ng_ipv6_nc_t *prev)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ng_ipv6_addr_t *ipv6_addr)
|
||||
ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ipv6_addr_t *ipv6_addr)
|
||||
{
|
||||
ng_ipv6_nc_t *entry = ng_ipv6_nc_get(KERNEL_PID_UNDEF, ipv6_addr);
|
||||
|
||||
if (entry == NULL) {
|
||||
DEBUG("ipv6_nc: No entry found for %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ ng_ipv6_nc_t *ng_ipv6_nc_still_reachable(const ng_ipv6_addr_t *ipv6_addr)
|
||||
#endif
|
||||
|
||||
DEBUG("ipv6_nc: Marking entry %s as reachable\n",
|
||||
ng_ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, ipv6_addr, sizeof(addr_str)));
|
||||
entry->flags &= ~(NG_IPV6_NC_STATE_MASK >> NG_IPV6_NC_STATE_POS);
|
||||
entry->flags |= (NG_IPV6_NC_STATE_REACHABLE >> NG_IPV6_NC_STATE_POS);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "kernel_types.h"
|
||||
#include "mutex.h"
|
||||
#include "net/eui64.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ndp.h"
|
||||
#include "net/ng_netapi.h"
|
||||
#include "net/ng_netif.h"
|
||||
@ -41,51 +41,51 @@
|
||||
static ng_ipv6_netif_t ipv6_ifs[NG_NETIF_NUMOF];
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
static ng_ipv6_addr_t *_add_addr_to_entry(ng_ipv6_netif_t *entry, const ng_ipv6_addr_t *addr,
|
||||
uint8_t prefix_len, uint8_t flags)
|
||||
static ipv6_addr_t *_add_addr_to_entry(ng_ipv6_netif_t *entry, const ipv6_addr_t *addr,
|
||||
uint8_t prefix_len, uint8_t flags)
|
||||
{
|
||||
ng_ipv6_netif_addr_t *tmp_addr = NULL;
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
|
||||
if (ng_ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
if (ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
return &(entry->addrs[i].addr);
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_unspecified(&(entry->addrs[i].addr)) && !tmp_addr) {
|
||||
if (ipv6_addr_is_unspecified(&(entry->addrs[i].addr)) && !tmp_addr) {
|
||||
tmp_addr = &(entry->addrs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tmp_addr) {
|
||||
DEBUG("ipv6 netif: couldn't add %s/%" PRIu8 " to interface %" PRIkernel_pid "\n: No space left.",
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
prefix_len, entry->pid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(&(tmp_addr->addr), addr, sizeof(ng_ipv6_addr_t));
|
||||
memcpy(&(tmp_addr->addr), addr, sizeof(ipv6_addr_t));
|
||||
DEBUG("ipv6 netif: Added %s/%" PRIu8 " to interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
prefix_len, entry->pid);
|
||||
|
||||
tmp_addr->prefix_len = prefix_len;
|
||||
tmp_addr->flags = flags;
|
||||
|
||||
if (ng_ipv6_addr_is_multicast(addr)) {
|
||||
if (ipv6_addr_is_multicast(addr)) {
|
||||
tmp_addr->flags |= NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST;
|
||||
}
|
||||
else {
|
||||
ng_ipv6_addr_t sol_node;
|
||||
ipv6_addr_t sol_node;
|
||||
|
||||
if (!ng_ipv6_addr_is_link_local(addr)) {
|
||||
if (!ipv6_addr_is_link_local(addr)) {
|
||||
/* add also corresponding link-local address */
|
||||
ng_ipv6_addr_t ll_addr;
|
||||
ipv6_addr_t ll_addr;
|
||||
|
||||
ll_addr.u64[1] = addr->u64[1];
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr);
|
||||
|
||||
_add_addr_to_entry(entry, &ll_addr, 64,
|
||||
flags | NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK);
|
||||
@ -94,8 +94,8 @@ static ng_ipv6_addr_t *_add_addr_to_entry(ng_ipv6_netif_t *entry, const ng_ipv6_
|
||||
tmp_addr->flags |= NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_set_solicited_nodes(&sol_node, addr);
|
||||
_add_addr_to_entry(entry, &sol_node, NG_IPV6_ADDR_BIT_LEN, 0);
|
||||
ipv6_addr_set_solicited_nodes(&sol_node, addr);
|
||||
_add_addr_to_entry(entry, &sol_node, IPV6_ADDR_BIT_LEN, 0);
|
||||
}
|
||||
|
||||
return &(tmp_addr->addr);
|
||||
@ -141,7 +141,7 @@ void ng_ipv6_netif_add(kernel_pid_t pid)
|
||||
|
||||
/* Otherwise, fill the free entry */
|
||||
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
ipv6_addr_t addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
mutex_lock(&free_entry->mutex);
|
||||
|
||||
DEBUG("ipv6 netif: Add IPv6 interface %" PRIkernel_pid " (i = %d)\n", pid,
|
||||
@ -151,7 +151,7 @@ void ng_ipv6_netif_add(kernel_pid_t pid)
|
||||
free_entry->cur_hl = NG_IPV6_NETIF_DEFAULT_HL;
|
||||
free_entry->flags = 0;
|
||||
|
||||
_add_addr_to_entry(free_entry, &addr, NG_IPV6_ADDR_BIT_LEN, 0);
|
||||
_add_addr_to_entry(free_entry, &addr, IPV6_ADDR_BIT_LEN, 0);
|
||||
|
||||
mutex_unlock(&free_entry->mutex);
|
||||
|
||||
@ -200,13 +200,13 @@ ng_ipv6_netif_t *ng_ipv6_netif_get(kernel_pid_t pid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *addr,
|
||||
uint8_t prefix_len, uint8_t flags)
|
||||
ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ipv6_addr_t *addr,
|
||||
uint8_t prefix_len, uint8_t flags)
|
||||
{
|
||||
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
|
||||
ng_ipv6_addr_t *res;
|
||||
ipv6_addr_t *res;
|
||||
|
||||
if ((entry == NULL) || (addr == NULL) || (ng_ipv6_addr_is_unspecified(addr)) ||
|
||||
if ((entry == NULL) || (addr == NULL) || (ipv6_addr_is_unspecified(addr)) ||
|
||||
((prefix_len - 1) > 127)) { /* prefix_len < 1 || prefix_len > 128 */
|
||||
return NULL;
|
||||
}
|
||||
@ -220,15 +220,15 @@ ng_ipv6_addr_t *ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *a
|
||||
return res;
|
||||
}
|
||||
|
||||
static void _remove_addr_from_entry(ng_ipv6_netif_t *entry, ng_ipv6_addr_t *addr)
|
||||
static void _remove_addr_from_entry(ng_ipv6_netif_t *entry, ipv6_addr_t *addr)
|
||||
{
|
||||
mutex_lock(&entry->mutex);
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
|
||||
if (ng_ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
if (ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
DEBUG("ipv6 netif: Remove %s to interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), entry->pid);
|
||||
ng_ipv6_addr_set_unspecified(&(entry->addrs[i].addr));
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), entry->pid);
|
||||
ipv6_addr_set_unspecified(&(entry->addrs[i].addr));
|
||||
entry->addrs[i].flags = 0;
|
||||
|
||||
mutex_unlock(&entry->mutex);
|
||||
@ -239,7 +239,7 @@ static void _remove_addr_from_entry(ng_ipv6_netif_t *entry, ng_ipv6_addr_t *addr
|
||||
mutex_unlock(&entry->mutex);
|
||||
}
|
||||
|
||||
void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ng_ipv6_addr_t *addr)
|
||||
void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ipv6_addr_t *addr)
|
||||
{
|
||||
if (pid == KERNEL_PID_UNDEF) {
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
@ -272,7 +272,7 @@ void ng_ipv6_netif_reset_addr(kernel_pid_t pid)
|
||||
mutex_unlock(&entry->mutex);
|
||||
}
|
||||
|
||||
kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out, const ng_ipv6_addr_t *addr)
|
||||
kernel_pid_t ng_ipv6_netif_find_by_addr(ipv6_addr_t **out, const ipv6_addr_t *addr)
|
||||
{
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
if (out != NULL) {
|
||||
@ -280,7 +280,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out, const ng_ipv6_addr
|
||||
|
||||
if (*out != NULL) {
|
||||
DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
|
||||
ipv6_ifs[i].pid);
|
||||
return ipv6_ifs[i].pid;
|
||||
}
|
||||
@ -301,7 +301,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out, const ng_ipv6_addr
|
||||
return KERNEL_PID_UNDEF;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ng_ipv6_addr_t *addr)
|
||||
ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ipv6_addr_t *addr)
|
||||
{
|
||||
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
|
||||
|
||||
@ -312,10 +312,10 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ng_ipv6_addr_t *
|
||||
mutex_lock(&entry->mutex);
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
|
||||
if (ng_ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
if (ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
|
||||
mutex_unlock(&entry->mutex);
|
||||
DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
pid);
|
||||
return &(entry->addrs[i].addr);
|
||||
}
|
||||
@ -326,8 +326,8 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ng_ipv6_addr_t *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *iface,
|
||||
const ng_ipv6_addr_t *addr, bool src_search)
|
||||
static uint8_t _find_by_prefix_unsafe(ipv6_addr_t **res, ng_ipv6_netif_t *iface,
|
||||
const ipv6_addr_t *addr, bool src_search)
|
||||
{
|
||||
uint8_t best_match = 0;
|
||||
|
||||
@ -336,13 +336,13 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
|
||||
|
||||
if ((src_search &&
|
||||
ng_ipv6_netif_addr_is_non_unicast(&(iface->addrs[i].addr))) ||
|
||||
ng_ipv6_addr_is_unspecified(&(iface->addrs[i].addr))) {
|
||||
ipv6_addr_is_unspecified(&(iface->addrs[i].addr))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
match = ng_ipv6_addr_match_prefix(&(iface->addrs[i].addr), addr);
|
||||
match = ipv6_addr_match_prefix(&(iface->addrs[i].addr), addr);
|
||||
|
||||
if (!src_search && !ng_ipv6_addr_is_multicast(addr) &&
|
||||
if (!src_search && !ipv6_addr_is_multicast(addr) &&
|
||||
(match < iface->addrs[i].prefix_len)) {
|
||||
/* match but not of same subnet */
|
||||
continue;
|
||||
@ -360,10 +360,10 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
|
||||
#if ENABLE_DEBUG
|
||||
if (*res != NULL) {
|
||||
DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid " matching ",
|
||||
ng_ipv6_addr_to_str(addr_str, *res, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, *res, sizeof(addr_str)),
|
||||
iface->pid);
|
||||
DEBUG("%s by %" PRIu8 " bits (used as source address = %s)\n",
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
best_match,
|
||||
(src_search) ? "true" : "false");
|
||||
}
|
||||
@ -371,7 +371,7 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
|
||||
DEBUG("ipv6 netif: Did not found any address on interface %" PRIkernel_pid
|
||||
" matching %s (used as source address = %s)\n",
|
||||
iface->pid,
|
||||
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
|
||||
(src_search) ? "true" : "false");
|
||||
}
|
||||
#endif
|
||||
@ -379,10 +379,10 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
|
||||
return best_match;
|
||||
}
|
||||
|
||||
kernel_pid_t ng_ipv6_netif_find_by_prefix(ng_ipv6_addr_t **out, const ng_ipv6_addr_t *prefix)
|
||||
kernel_pid_t ng_ipv6_netif_find_by_prefix(ipv6_addr_t **out, const ipv6_addr_t *prefix)
|
||||
{
|
||||
uint8_t best_match = 0;
|
||||
ng_ipv6_addr_t *tmp_res = NULL;
|
||||
ipv6_addr_t *tmp_res = NULL;
|
||||
kernel_pid_t res = KERNEL_PID_UNDEF;
|
||||
|
||||
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
|
||||
@ -407,25 +407,25 @@ kernel_pid_t ng_ipv6_netif_find_by_prefix(ng_ipv6_addr_t **out, const ng_ipv6_ad
|
||||
#if ENABLE_DEBUG
|
||||
if (res != KERNEL_PID_UNDEF) {
|
||||
DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid " globally matching ",
|
||||
ng_ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
|
||||
res);
|
||||
DEBUG("%s by %" PRIu8 " bits\n",
|
||||
ng_ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)),
|
||||
best_match);
|
||||
}
|
||||
else {
|
||||
DEBUG("ipv6 netif: Did not found any address globally matching %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)));
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static ng_ipv6_addr_t *_match_prefix(kernel_pid_t pid, const ng_ipv6_addr_t *addr,
|
||||
bool src_search)
|
||||
static ipv6_addr_t *_match_prefix(kernel_pid_t pid, const ipv6_addr_t *addr,
|
||||
bool src_search)
|
||||
{
|
||||
ng_ipv6_addr_t *res = NULL;
|
||||
ipv6_addr_t *res = NULL;
|
||||
ng_ipv6_netif_t *iface = ng_ipv6_netif_get(pid);
|
||||
|
||||
mutex_lock(&(iface->mutex));
|
||||
@ -440,13 +440,12 @@ static ng_ipv6_addr_t *_match_prefix(kernel_pid_t pid, const ng_ipv6_addr_t *add
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid,
|
||||
const ng_ipv6_addr_t *prefix)
|
||||
ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid, const ipv6_addr_t *prefix)
|
||||
{
|
||||
return _match_prefix(pid, prefix, false);
|
||||
}
|
||||
|
||||
ng_ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ng_ipv6_addr_t *dest)
|
||||
ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ipv6_addr_t *dest)
|
||||
{
|
||||
return _match_prefix(pid, dest, true);
|
||||
}
|
||||
@ -457,7 +456,7 @@ void ng_ipv6_netif_init_by_dev(void)
|
||||
size_t ifnum = ng_netif_get(ifs);
|
||||
|
||||
for (size_t i = 0; i < ifnum; i++) {
|
||||
ng_ipv6_addr_t addr;
|
||||
ipv6_addr_t addr;
|
||||
eui64_t iid;
|
||||
ng_ipv6_netif_t *ipv6_if = ng_ipv6_netif_get(ifs[i]);
|
||||
|
||||
@ -500,8 +499,8 @@ void ng_ipv6_netif_init_by_dev(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
ng_ipv6_addr_set_aiid(&addr, iid.uint8);
|
||||
ng_ipv6_addr_set_link_local_prefix(&addr);
|
||||
ipv6_addr_set_aiid(&addr, iid.uint8);
|
||||
ipv6_addr_set_link_local_prefix(&addr);
|
||||
_add_addr_to_entry(ipv6_if, &addr, 64, 0);
|
||||
|
||||
mutex_unlock(&ipv6_if->mutex);
|
||||
|
@ -42,7 +42,7 @@ static char _stack[NG_IPV6_STACK_SIZE];
|
||||
#endif
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
kernel_pid_t ng_ipv6_pid = KERNEL_PID_UNDEF;
|
||||
@ -171,7 +171,7 @@ static void *_event_loop(void *args)
|
||||
case NG_NDP_MSG_ADDR_TIMEOUT:
|
||||
DEBUG("ipv6: Router advertisement timer event received\n");
|
||||
ng_ipv6_netif_remove_addr(KERNEL_PID_UNDEF,
|
||||
(ng_ipv6_addr_t *)msg.content.ptr);
|
||||
(ipv6_addr_t *)msg.content.ptr);
|
||||
break;
|
||||
|
||||
case NG_NDP_MSG_NBR_SOL_RETRANS:
|
||||
@ -282,17 +282,17 @@ static int _fill_ipv6_hdr(kernel_pid_t iface, ng_pktsnip_t *ipv6,
|
||||
}
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_unspecified(&hdr->src)) {
|
||||
if (ng_ipv6_addr_is_loopback(&hdr->dst)) {
|
||||
ng_ipv6_addr_set_loopback(&hdr->src);
|
||||
if (ipv6_addr_is_unspecified(&hdr->src)) {
|
||||
if (ipv6_addr_is_loopback(&hdr->dst)) {
|
||||
ipv6_addr_set_loopback(&hdr->src);
|
||||
}
|
||||
else {
|
||||
ng_ipv6_addr_t *src = ng_ipv6_netif_find_best_src_addr(iface, &hdr->dst);
|
||||
ipv6_addr_t *src = ng_ipv6_netif_find_best_src_addr(iface, &hdr->dst);
|
||||
|
||||
if (src != NULL) {
|
||||
DEBUG("ipv6: set packet source to %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, src, sizeof(addr_str)));
|
||||
memcpy(&hdr->src, src, sizeof(ng_ipv6_addr_t));
|
||||
ipv6_addr_to_str(addr_str, src, sizeof(addr_str)));
|
||||
memcpy(&hdr->src, src, sizeof(ipv6_addr_t));
|
||||
}
|
||||
/* Otherwise leave unspecified */
|
||||
}
|
||||
@ -451,7 +451,7 @@ static void _send_multicast(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
}
|
||||
|
||||
static inline kernel_pid_t _next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ng_ipv6_addr_t *dst,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
ng_pktsnip_t *pkt)
|
||||
{
|
||||
#ifdef MODULE_NG_NDP_NODE
|
||||
@ -470,7 +470,7 @@ static void _send(ng_pktsnip_t *pkt, bool prep_hdr)
|
||||
{
|
||||
kernel_pid_t iface = KERNEL_PID_UNDEF;
|
||||
ng_pktsnip_t *ipv6, *payload;
|
||||
ng_ipv6_addr_t *tmp;
|
||||
ipv6_addr_t *tmp;
|
||||
ng_ipv6_hdr_t *hdr;
|
||||
/* get IPv6 snip and (if present) generic interface header */
|
||||
if (pkt->type == NG_NETTYPE_NETIF) {
|
||||
@ -507,10 +507,10 @@ static void _send(ng_pktsnip_t *pkt, bool prep_hdr)
|
||||
hdr = ipv6->data;
|
||||
payload = ipv6->next;
|
||||
|
||||
if (ng_ipv6_addr_is_multicast(&hdr->dst)) {
|
||||
if (ipv6_addr_is_multicast(&hdr->dst)) {
|
||||
_send_multicast(iface, pkt, ipv6, payload, prep_hdr);
|
||||
}
|
||||
else if ((ng_ipv6_addr_is_loopback(&hdr->dst)) || /* dst is loopback address */
|
||||
else if ((ipv6_addr_is_loopback(&hdr->dst)) || /* dst is loopback address */
|
||||
((iface == KERNEL_PID_UNDEF) && /* or dst registered to any local interface */
|
||||
((iface = ng_ipv6_netif_find_by_addr(&tmp, &hdr->dst)) != KERNEL_PID_UNDEF)) ||
|
||||
((iface != KERNEL_PID_UNDEF) && /* or dst registered to given interface */
|
||||
@ -576,7 +576,7 @@ static void _send(ng_pktsnip_t *pkt, bool prep_hdr)
|
||||
/* functions for receiving */
|
||||
static inline bool _pkt_not_for_me(kernel_pid_t *iface, ng_ipv6_hdr_t *hdr)
|
||||
{
|
||||
if (ng_ipv6_addr_is_loopback(&hdr->dst)) {
|
||||
if (ipv6_addr_is_loopback(&hdr->dst)) {
|
||||
return false;
|
||||
}
|
||||
else if (*iface == KERNEL_PID_UNDEF) {
|
||||
@ -657,9 +657,9 @@ static void _receive(ng_pktsnip_t *pkt)
|
||||
hdr = (ng_ipv6_hdr_t *)ipv6->data;
|
||||
|
||||
DEBUG("ipv6: Received (src = %s, ",
|
||||
ng_ipv6_addr_to_str(addr_str, &(hdr->src), sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &(hdr->src), sizeof(addr_str)));
|
||||
DEBUG("dst = %s, next header = %" PRIu8 ", length = %" PRIu16 ")\n",
|
||||
ng_ipv6_addr_to_str(addr_str, &(hdr->dst), sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, &(hdr->dst), sizeof(addr_str)),
|
||||
hdr->nh, byteorder_ntohs(hdr->len));
|
||||
|
||||
if (_pkt_not_for_me(&iface, hdr)) { /* if packet is not for me */
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
static ng_ipv6_nc_t *_last_router = NULL; /* last router chosen as default
|
||||
@ -53,7 +53,7 @@ static inline void _send_delayed(vtimer_t *t, timex_t interval, ng_pktsnip_t *pk
|
||||
}
|
||||
|
||||
|
||||
ng_ipv6_addr_t *ng_ndp_internal_default_router(void)
|
||||
ipv6_addr_t *ng_ndp_internal_default_router(void)
|
||||
{
|
||||
ng_ipv6_nc_t *router = ng_ipv6_nc_get_next_router(NULL);
|
||||
|
||||
@ -94,7 +94,7 @@ void ng_ndp_internal_set_state(ng_ipv6_nc_t *nc_entry, uint8_t state)
|
||||
nc_entry->flags |= state;
|
||||
|
||||
DEBUG("ndp internal: set %s state to ",
|
||||
ng_ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
|
||||
switch (state) {
|
||||
case NG_IPV6_NC_STATE_REACHABLE:
|
||||
@ -149,24 +149,23 @@ void ng_ndp_internal_set_state(ng_ipv6_nc_t *nc_entry, uint8_t state)
|
||||
}
|
||||
}
|
||||
|
||||
void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
ng_ipv6_addr_t *dst, bool supply_tl2a)
|
||||
void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst, bool supply_tl2a)
|
||||
{
|
||||
ng_pktsnip_t *hdr, *pkt = NULL;
|
||||
uint8_t adv_flags = 0;
|
||||
|
||||
DEBUG("ndp internal: send neighbor advertisement (iface: %" PRIkernel_pid ", tgt: %s, ",
|
||||
iface, ng_ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
|
||||
iface, ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
|
||||
DEBUG("dst: %s, supply_tl2a: %d)\n",
|
||||
ng_ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)), supply_tl2a);
|
||||
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)), supply_tl2a);
|
||||
|
||||
if (ng_ipv6_netif_get(iface)->flags & NG_IPV6_NETIF_FLAGS_ROUTER) {
|
||||
adv_flags |= NG_NDP_NBR_ADV_FLAGS_R;
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_unspecified(dst)) {
|
||||
ng_ipv6_addr_set_all_nodes_multicast(dst,
|
||||
NG_IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
|
||||
if (ipv6_addr_is_unspecified(dst)) {
|
||||
ipv6_addr_set_all_nodes_multicast(dst, IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
|
||||
}
|
||||
else {
|
||||
adv_flags |= NG_NDP_NBR_ADV_FLAGS_S;
|
||||
@ -206,7 +205,7 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
|
||||
pkt = hdr;
|
||||
hdr = ng_ipv6_hdr_build(pkt, NULL, 0, (uint8_t *)dst,
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
if (hdr == NULL) {
|
||||
DEBUG("ndp internal: error allocating IPv6 header.\n");
|
||||
@ -246,22 +245,22 @@ void ng_ndp_internal_send_nbr_adv(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
}
|
||||
}
|
||||
|
||||
void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
ng_ipv6_addr_t *dst)
|
||||
void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ipv6_addr_t *tgt,
|
||||
ipv6_addr_t *dst)
|
||||
{
|
||||
ng_pktsnip_t *hdr, *pkt = NULL;
|
||||
ng_ipv6_addr_t *src = NULL;
|
||||
ipv6_addr_t *src = NULL;
|
||||
size_t src_len = 0;
|
||||
|
||||
DEBUG("ndp internal: send neighbor solicitation (iface: %" PRIkernel_pid ", tgt: %s, ",
|
||||
iface, ng_ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
|
||||
DEBUG("dst: %s)\n", ng_ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
|
||||
iface, ipv6_addr_to_str(addr_str, tgt, sizeof(addr_str)));
|
||||
DEBUG("dst: %s)\n", ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
|
||||
|
||||
/* check if there is a fitting source address to target */
|
||||
if ((src = ng_ipv6_netif_find_best_src_addr(iface, tgt)) != NULL) {
|
||||
uint8_t l2src[8];
|
||||
uint16_t l2src_len;
|
||||
src_len = sizeof(ng_ipv6_addr_t);
|
||||
src_len = sizeof(ipv6_addr_t);
|
||||
l2src_len = _get_l2src(l2src, sizeof(l2src), iface);
|
||||
|
||||
if (l2src_len > 0) {
|
||||
@ -286,7 +285,7 @@ void ng_ndp_internal_send_nbr_sol(kernel_pid_t iface, ng_ipv6_addr_t *tgt,
|
||||
|
||||
pkt = hdr;
|
||||
hdr = ng_ipv6_hdr_build(pkt, (uint8_t *)src, src_len, (uint8_t *)dst,
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
if (hdr == NULL) {
|
||||
DEBUG("ndp internal: error allocating IPv6 header.\n");
|
||||
@ -320,7 +319,7 @@ bool ng_ndp_internal_sl2a_opt_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
uint8_t sl2a_len = 0;
|
||||
uint8_t *sl2a = (uint8_t *)(sl2a_opt + 1);
|
||||
|
||||
if ((sl2a_opt->len == 0) || ng_ipv6_addr_is_unspecified(&ipv6->src)) {
|
||||
if ((sl2a_opt->len == 0) || ipv6_addr_is_unspecified(&ipv6->src)) {
|
||||
DEBUG("ndp: invalid source link-layer address option received\n");
|
||||
return false;
|
||||
}
|
||||
@ -379,7 +378,7 @@ int ng_ndp_internal_tl2a_opt_handle(ng_pktsnip_t *pkt, ng_ipv6_hdr_t *ipv6,
|
||||
uint8_t tl2a_len = 0;
|
||||
uint8_t *tl2a = (uint8_t *)(tl2a_opt + 1);
|
||||
|
||||
if ((tl2a_opt->len == 0) || ng_ipv6_addr_is_unspecified(&ipv6->src)) {
|
||||
if ((tl2a_opt->len == 0) || ipv6_addr_is_unspecified(&ipv6->src)) {
|
||||
DEBUG("ndp: invalid target link-layer address option received\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@
|
||||
/* For PRIu8 etc. */
|
||||
#include <inttypes.h>
|
||||
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
/* random helper function */
|
||||
@ -50,22 +50,22 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
{
|
||||
uint16_t opt_offset = 0;
|
||||
uint8_t *buf = ((uint8_t *)nbr_sol) + sizeof(ng_ndp_nbr_sol_t);
|
||||
ng_ipv6_addr_t *tgt;
|
||||
ipv6_addr_t *tgt;
|
||||
int sicmpv6_size = (int)icmpv6_size;
|
||||
|
||||
DEBUG("ndp: received neighbor solicitation (src: %s, ",
|
||||
ng_ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
||||
DEBUG("dst: %s, ",
|
||||
ng_ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
|
||||
DEBUG("tgt: %s)\n",
|
||||
ng_ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
|
||||
|
||||
/* check validity */
|
||||
if ((ipv6->hl != 255) || (nbr_sol->code != 0) ||
|
||||
(icmpv6_size < sizeof(ng_ndp_nbr_sol_t)) ||
|
||||
ng_ipv6_addr_is_multicast(&nbr_sol->tgt) ||
|
||||
(ng_ipv6_addr_is_unspecified(&ipv6->src) &&
|
||||
ng_ipv6_addr_is_solicited_node(&ipv6->dst))) {
|
||||
ipv6_addr_is_multicast(&nbr_sol->tgt) ||
|
||||
(ipv6_addr_is_unspecified(&ipv6->src) &&
|
||||
ipv6_addr_is_solicited_node(&ipv6->dst))) {
|
||||
DEBUG("ndp: neighbor solicitation was invalid.\n");
|
||||
/* ipv6 releases */
|
||||
return;
|
||||
@ -102,7 +102,7 @@ void ng_ndp_nbr_sol_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
}
|
||||
|
||||
ng_ndp_internal_send_nbr_adv(iface, tgt, &ipv6->src,
|
||||
ng_ipv6_addr_is_multicast(&ipv6->dst));
|
||||
ipv6_addr_is_multicast(&ipv6->dst));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -127,16 +127,16 @@ void ng_ndp_nbr_adv_handle(kernel_pid_t iface, ng_pktsnip_t *pkt,
|
||||
ng_netif_hdr_t *netif_hdr = NULL;
|
||||
|
||||
DEBUG("ndp: received neighbor advertisement (src: %s, ",
|
||||
ng_ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &ipv6->src, sizeof(addr_str)));
|
||||
DEBUG("dst: %s, ",
|
||||
ng_ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
|
||||
DEBUG("tgt: %s)\n",
|
||||
ng_ipv6_addr_to_str(addr_str, &nbr_adv->tgt, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &nbr_adv->tgt, sizeof(addr_str)));
|
||||
|
||||
/* check validity */
|
||||
if ((ipv6->hl != 255) || (nbr_adv->code != 0) ||
|
||||
(icmpv6_size < sizeof(ng_ndp_nbr_adv_t)) ||
|
||||
ng_ipv6_addr_is_multicast(&nbr_adv->tgt)) {
|
||||
ipv6_addr_is_multicast(&nbr_adv->tgt)) {
|
||||
DEBUG("ndp: neighbor advertisement was invalid.\n");
|
||||
/* ipv6 releases */
|
||||
return;
|
||||
@ -265,14 +265,14 @@ void ng_ndp_retrans_nbr_sol(ng_ipv6_nc_t *nc_entry)
|
||||
if ((ng_ipv6_nc_get_state(nc_entry) == NG_IPV6_NC_STATE_INCOMPLETE) ||
|
||||
(ng_ipv6_nc_get_state(nc_entry) == NG_IPV6_NC_STATE_PROBE)) {
|
||||
if (nc_entry->probes_remaining > 1) {
|
||||
ng_ipv6_addr_t dst;
|
||||
ipv6_addr_t dst;
|
||||
|
||||
DEBUG("ndp: Retransmit neighbor solicitation for %s\n",
|
||||
ng_ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
|
||||
/* retransmit neighbor solicatation */
|
||||
if (ng_ipv6_nc_get_state(nc_entry) == NG_IPV6_NC_STATE_INCOMPLETE) {
|
||||
ng_ipv6_addr_set_solicited_nodes(&dst, &nc_entry->ipv6_addr);
|
||||
ipv6_addr_set_solicited_nodes(&dst, &nc_entry->ipv6_addr);
|
||||
}
|
||||
else {
|
||||
dst.u64[0] = nc_entry->ipv6_addr.u64[0];
|
||||
@ -309,11 +309,11 @@ void ng_ndp_retrans_nbr_sol(ng_ipv6_nc_t *nc_entry)
|
||||
}
|
||||
else if (nc_entry->probes_remaining <= 1) {
|
||||
DEBUG("ndp: Remove nc entry %s for interface %" PRIkernel_pid "\n",
|
||||
ng_ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)),
|
||||
ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)),
|
||||
nc_entry->iface);
|
||||
|
||||
#ifdef MODULE_FIB
|
||||
fib_remove_entry((uint8_t *) & (nc_entry->ipv6_addr), sizeof(ng_ipv6_addr_t));
|
||||
fib_remove_entry((uint8_t *) & (nc_entry->ipv6_addr), sizeof(ipv6_addr_t));
|
||||
#endif
|
||||
ng_ipv6_nc_remove(nc_entry->iface, &nc_entry->ipv6_addr);
|
||||
}
|
||||
@ -357,13 +357,13 @@ void ng_ndp_netif_remove(ng_ipv6_netif_t *iface)
|
||||
(void) iface;
|
||||
}
|
||||
|
||||
ng_pktsnip_t *ng_ndp_nbr_sol_build(ng_ipv6_addr_t *tgt, ng_pktsnip_t *options)
|
||||
ng_pktsnip_t *ng_ndp_nbr_sol_build(ipv6_addr_t *tgt, ng_pktsnip_t *options)
|
||||
{
|
||||
ng_pktsnip_t *pkt;
|
||||
|
||||
DEBUG("ndp: building neighbor solicitation message\n");
|
||||
|
||||
if (ng_ipv6_addr_is_multicast(tgt)) {
|
||||
if (ipv6_addr_is_multicast(tgt)) {
|
||||
DEBUG("ndp: tgt must not be multicast\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -380,14 +380,14 @@ ng_pktsnip_t *ng_ndp_nbr_sol_build(ng_ipv6_addr_t *tgt, ng_pktsnip_t *options)
|
||||
return pkt;
|
||||
}
|
||||
|
||||
ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ng_ipv6_addr_t *tgt,
|
||||
ng_pktsnip_t *ng_ndp_nbr_adv_build(uint8_t flags, ipv6_addr_t *tgt,
|
||||
ng_pktsnip_t *options)
|
||||
{
|
||||
ng_pktsnip_t *pkt;
|
||||
|
||||
DEBUG("ndp: building neighbor advertisement message\n");
|
||||
|
||||
if (ng_ipv6_addr_is_multicast(tgt)) {
|
||||
if (ipv6_addr_is_multicast(tgt)) {
|
||||
DEBUG("ndp: tgt must not be multicast\n");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "debug.h"
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char addr_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
static ng_pktqueue_t _pkt_nodes[NG_IPV6_NC_SIZE * 2];
|
||||
@ -56,10 +56,10 @@ static ng_pktqueue_t *_alloc_pkt_node(ng_pktsnip_t *pkt)
|
||||
}
|
||||
|
||||
kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
kernel_pid_t iface, ng_ipv6_addr_t *dst,
|
||||
kernel_pid_t iface, ipv6_addr_t *dst,
|
||||
ng_pktsnip_t *pkt)
|
||||
{
|
||||
ng_ipv6_addr_t *next_hop_ip = NULL, *prefix = NULL;
|
||||
ipv6_addr_t *next_hop_ip = NULL, *prefix = NULL;
|
||||
|
||||
#ifdef MODULE_NG_IPV6_EXT_RH
|
||||
next_hop_ip = ng_ipv6_ext_rh_next_hop(hdr);
|
||||
@ -67,13 +67,13 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
#ifdef MODULE_FIB
|
||||
size_t next_hop_size;
|
||||
uint32_t next_hop_flags = 0;
|
||||
ng_ipv6_addr_t next_hop_actual; /* FIB copies address into this variable */
|
||||
ipv6_addr_t next_hop_actual; /* FIB copies address into this variable */
|
||||
|
||||
if ((next_hop_ip == NULL) &&
|
||||
(fib_get_next_hop(&iface, next_hop_actual.u8, &next_hop_size,
|
||||
&next_hop_flags, (uint8_t *)dst,
|
||||
sizeof(ng_ipv6_addr_t), 0) >= 0) &&
|
||||
(next_hop_size == sizeof(ng_ipv6_addr_t))) {
|
||||
sizeof(ipv6_addr_t), 0) >= 0) &&
|
||||
(next_hop_size == sizeof(ipv6_addr_t))) {
|
||||
next_hop_ip = &next_hop_actual;
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
#ifdef MODULE_FIB
|
||||
/* We don't care if FIB is full, this is just for efficiency
|
||||
* for later sends */
|
||||
fib_add_entry(iface, (uint8_t *)dst, sizeof(ng_ipv6_addr_t), 0,
|
||||
(uint8_t *)next_hop_ip, sizeof(ng_ipv6_addr_t), 0,
|
||||
fib_add_entry(iface, (uint8_t *)dst, sizeof(ipv6_addr_t), 0,
|
||||
(uint8_t *)next_hop_ip, sizeof(ipv6_addr_t), 0,
|
||||
FIB_LIFETIME_NO_EXPIRE);
|
||||
#endif
|
||||
}
|
||||
@ -108,8 +108,8 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
#ifdef MODULE_FIB
|
||||
/* We don't care if FIB is full, this is just for efficiency for later
|
||||
* sends */
|
||||
fib_add_entry(iface, (uint8_t *)dst, sizeof(ng_ipv6_addr_t), 0,
|
||||
(uint8_t *)next_hop_ip, sizeof(ng_ipv6_addr_t), 0,
|
||||
fib_add_entry(iface, (uint8_t *)dst, sizeof(ipv6_addr_t), 0,
|
||||
(uint8_t *)next_hop_ip, sizeof(ipv6_addr_t), 0,
|
||||
FIB_LIFETIME_NO_EXPIRE);
|
||||
#endif
|
||||
}
|
||||
@ -119,7 +119,7 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
|
||||
if ((nc_entry != NULL) && ng_ipv6_nc_is_reachable(nc_entry)) {
|
||||
DEBUG("ndp node: found reachable neighbor (%s => ",
|
||||
ng_ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
ipv6_addr_to_str(addr_str, &nc_entry->ipv6_addr, sizeof(addr_str)));
|
||||
DEBUG("%s)\n",
|
||||
ng_netif_addr_to_str(addr_str, sizeof(addr_str),
|
||||
nc_entry->l2_addr, nc_entry->l2_addr_len));
|
||||
@ -135,7 +135,7 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
}
|
||||
else if (nc_entry == NULL) {
|
||||
ng_pktqueue_t *pkt_node;
|
||||
ng_ipv6_addr_t dst_sol;
|
||||
ipv6_addr_t dst_sol;
|
||||
|
||||
nc_entry = ng_ipv6_nc_add(iface, next_hop_ip, NULL, 0,
|
||||
NG_IPV6_NC_STATE_INCOMPLETE << NG_IPV6_NC_STATE_POS);
|
||||
@ -157,7 +157,7 @@ kernel_pid_t ng_ndp_node_next_hop_l2addr(uint8_t *l2addr, uint8_t *l2addr_len,
|
||||
}
|
||||
|
||||
/* address resolution */
|
||||
ng_ipv6_addr_set_solicited_nodes(&dst_sol, next_hop_ip);
|
||||
ipv6_addr_set_solicited_nodes(&dst_sol, next_hop_ip);
|
||||
|
||||
if (iface == KERNEL_PID_UNDEF) {
|
||||
timex_t t = { 0, NG_NDP_RETRANS_TIMER };
|
||||
|
@ -30,7 +30,7 @@ static uint32_t _current_minute(void);
|
||||
static void _update_lifetime(uint8_t id);
|
||||
|
||||
#if ENABLE_DEBUG
|
||||
static char ipv6str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char ipv6str[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
static inline bool _valid(uint8_t id)
|
||||
@ -39,7 +39,7 @@ static inline bool _valid(uint8_t id)
|
||||
return (_ctxs[id].prefix_len > 0);
|
||||
}
|
||||
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ng_ipv6_addr_t *addr)
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ipv6_addr_t *addr)
|
||||
{
|
||||
uint8_t best = 0;
|
||||
ng_sixlowpan_ctx_t *res = NULL;
|
||||
@ -48,7 +48,7 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ng_ipv6_addr_t *addr)
|
||||
|
||||
for (unsigned int id = 0; id < NG_SIXLOWPAN_CTX_SIZE; id++) {
|
||||
if (_valid(id)) {
|
||||
uint8_t match = ng_ipv6_addr_match_prefix(&_ctxs[id].prefix, addr);
|
||||
uint8_t match = ipv6_addr_match_prefix(&_ctxs[id].prefix, addr);
|
||||
|
||||
if ((_ctxs[id].prefix_len <= match) && (match > best)) {
|
||||
best = match;
|
||||
@ -62,9 +62,9 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_addr(const ng_ipv6_addr_t *addr)
|
||||
#if ENABLE_DEBUG
|
||||
if (res != NULL) {
|
||||
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ") ", res->id,
|
||||
ng_ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
|
||||
ipv6_addr_to_str(ipv6str, &res->prefix, sizeof(ipv6str)),
|
||||
res->prefix_len);
|
||||
DEBUG("for address %s\n", ng_ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
|
||||
DEBUG("for address %s\n", ipv6_addr_to_str(ipv6str, addr, sizeof(ipv6str)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -81,7 +81,7 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_id(uint8_t id)
|
||||
|
||||
if (_valid(id)) {
|
||||
DEBUG("6lo ctx: found context (%u, %s/%" PRIu8 ")\n", id,
|
||||
ng_ipv6_addr_to_str(ipv6str, &_ctxs[id].prefix, sizeof(ipv6str)),
|
||||
ipv6_addr_to_str(ipv6str, &_ctxs[id].prefix, sizeof(ipv6str)),
|
||||
_ctxs[id].prefix_len);
|
||||
mutex_unlock(&_ctx_mutex);
|
||||
return &(_ctxs[id]);
|
||||
@ -92,7 +92,7 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_lookup_id(uint8_t id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ng_ipv6_addr_t *prefix,
|
||||
ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *prefix,
|
||||
uint8_t prefix_len, uint16_t ltime,
|
||||
bool comp)
|
||||
{
|
||||
@ -108,8 +108,8 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ng_ipv6_addr_t *pr
|
||||
comp = false;
|
||||
}
|
||||
|
||||
if (prefix_len > NG_IPV6_ADDR_BIT_LEN) {
|
||||
_ctxs[id].prefix_len = NG_IPV6_ADDR_BIT_LEN;
|
||||
if (prefix_len > IPV6_ADDR_BIT_LEN) {
|
||||
_ctxs[id].prefix_len = IPV6_ADDR_BIT_LEN;
|
||||
}
|
||||
else {
|
||||
_ctxs[id].prefix_len = prefix_len;
|
||||
@ -117,13 +117,12 @@ ng_sixlowpan_ctx_t *ng_sixlowpan_ctx_update(uint8_t id, const ng_ipv6_addr_t *pr
|
||||
|
||||
_ctxs[id].flags_id = (comp) ? (NG_SIXLOWPAN_CTX_FLAGS_COMP | id) : id;
|
||||
|
||||
if (!ng_ipv6_addr_equal(&(_ctxs[id].prefix), prefix)) {
|
||||
ng_ipv6_addr_set_unspecified(&(_ctxs[id].prefix));
|
||||
ng_ipv6_addr_init_prefix(&(_ctxs[id].prefix), prefix,
|
||||
_ctxs[id].prefix_len);
|
||||
if (!ipv6_addr_equal(&(_ctxs[id].prefix), prefix)) {
|
||||
ipv6_addr_set_unspecified(&(_ctxs[id].prefix));
|
||||
ipv6_addr_init_prefix(&(_ctxs[id].prefix), prefix, _ctxs[id].prefix_len);
|
||||
}
|
||||
DEBUG("6lo ctx: update context (%u, %s/%" PRIu8 "), lifetime: %" PRIu16 " min\n",
|
||||
id, ng_ipv6_addr_to_str(ipv6str, &_ctxs[id].prefix, sizeof(ipv6str)),
|
||||
id, ipv6_addr_to_str(ipv6str, &_ctxs[id].prefix, sizeof(ipv6str)),
|
||||
_ctxs[id].prefix_len, _ctxs[id].ltime);
|
||||
_ctx_inval_times[id] = ltime + _current_minute();
|
||||
|
||||
|
@ -69,7 +69,7 @@
|
||||
#define IPHC_M_DAC_DAM_M_UC_PREFIX (0x0c)
|
||||
|
||||
static inline bool _context_overlaps_iid(ng_sixlowpan_ctx_t *ctx,
|
||||
ng_ipv6_addr_t *addr,
|
||||
ipv6_addr_t *addr,
|
||||
eui64_t *iid)
|
||||
{
|
||||
uint8_t byte_mask[] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
@ -187,13 +187,13 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
break;
|
||||
|
||||
case IPHC_SAC_SAM_64:
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
memcpy(ipv6_hdr->src.u8 + 8, iphc_hdr + payload_offset, 8);
|
||||
payload_offset += 8;
|
||||
break;
|
||||
|
||||
case IPHC_SAC_SAM_16:
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
ipv6_hdr->src.u32[2] = byteorder_htonl(0x000000ff);
|
||||
ipv6_hdr->src.u16[6] = byteorder_htons(0xfe00);
|
||||
memcpy(ipv6_hdr->src.u8 + 14, iphc_hdr + payload_offset, 2);
|
||||
@ -204,17 +204,17 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ieee802154_get_iid((eui64_t *)(&ipv6_hdr->src.u64[1]),
|
||||
ng_netif_hdr_get_src_addr(netif_hdr),
|
||||
netif_hdr->src_l2addr_len);
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->src);
|
||||
break;
|
||||
|
||||
case IPHC_SAC_SAM_UNSPEC:
|
||||
ng_ipv6_addr_set_unspecified(&ipv6_hdr->src);
|
||||
ipv6_addr_set_unspecified(&ipv6_hdr->src);
|
||||
break;
|
||||
|
||||
case IPHC_SAC_SAM_CTX_64:
|
||||
memcpy(ipv6_hdr->src.u8 + 8, iphc_hdr + payload_offset, 8);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
payload_offset += 8;
|
||||
break;
|
||||
|
||||
@ -222,8 +222,8 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ipv6_hdr->src.u32[2] = byteorder_htonl(0x000000ff);
|
||||
ipv6_hdr->src.u16[6] = byteorder_htons(0xfe00);
|
||||
memcpy(ipv6_hdr->src.u8 + 14, iphc_hdr + payload_offset, 2);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
payload_offset += 2;
|
||||
break;
|
||||
|
||||
@ -231,8 +231,8 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ieee802154_get_iid((eui64_t *)(&ipv6_hdr->src.u64[1]),
|
||||
ng_netif_hdr_get_src_addr(netif_hdr),
|
||||
netif_hdr->src_l2addr_len);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->src, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -262,13 +262,13 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
break;
|
||||
|
||||
case IPHC_M_DAC_DAM_U_64:
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
memcpy(ipv6_hdr->dst.u8 + 8, iphc_hdr + payload_offset, 8);
|
||||
payload_offset += 8;
|
||||
break;
|
||||
|
||||
case IPHC_M_DAC_DAM_U_16:
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
ipv6_hdr->dst.u32[2] = byteorder_htonl(0x000000ff);
|
||||
ipv6_hdr->dst.u16[6] = byteorder_htons(0xfe00);
|
||||
memcpy(ipv6_hdr->dst.u8 + 14, iphc_hdr + payload_offset, 2);
|
||||
@ -279,13 +279,13 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ieee802154_get_iid((eui64_t *)(&ipv6_hdr->dst.u64[1]),
|
||||
ng_netif_hdr_get_dst_addr(netif_hdr),
|
||||
netif_hdr->dst_l2addr_len);
|
||||
ng_ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_link_local_prefix(&ipv6_hdr->dst);
|
||||
break;
|
||||
|
||||
case IPHC_M_DAC_DAM_U_CTX_64:
|
||||
memcpy(ipv6_hdr->dst.u8 + 8, iphc_hdr + payload_offset, 8);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
payload_offset += 8;
|
||||
break;
|
||||
|
||||
@ -293,8 +293,8 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ipv6_hdr->dst.u32[2] = byteorder_htonl(0x000000ff);
|
||||
ipv6_hdr->dst.u16[6] = byteorder_htons(0xfe00);
|
||||
memcpy(ipv6_hdr->dst.u8 + 14, iphc_hdr + payload_offset, 2);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
payload_offset += 2;
|
||||
break;
|
||||
|
||||
@ -302,13 +302,13 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ieee802154_get_iid((eui64_t *)(&ipv6_hdr->dst.u64[1]),
|
||||
ng_netif_hdr_get_dst_addr(netif_hdr),
|
||||
netif_hdr->dst_l2addr_len);
|
||||
ng_ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
ipv6_addr_init_prefix(&ipv6_hdr->dst, &ctx->prefix,
|
||||
ctx->prefix_len);
|
||||
break;
|
||||
|
||||
case IPHC_M_DAC_DAM_M_48:
|
||||
/* ffXX::00XX:XXXX:XXXX */
|
||||
ng_ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_hdr->dst.u8[0] = 0xff;
|
||||
ipv6_hdr->dst.u8[1] = iphc_hdr[payload_offset++];
|
||||
ipv6_hdr->dst.u8[11] = iphc_hdr[payload_offset++];
|
||||
@ -320,7 +320,7 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
|
||||
case IPHC_M_DAC_DAM_M_32:
|
||||
/* ffXX::00XX:XXXX */
|
||||
ng_ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_hdr->dst.u8[0] = 0xff;
|
||||
ipv6_hdr->dst.u8[1] = iphc_hdr[payload_offset++];
|
||||
ipv6_hdr->dst.u8[13] = iphc_hdr[payload_offset++];
|
||||
@ -330,7 +330,7 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
|
||||
case IPHC_M_DAC_DAM_M_8:
|
||||
/* ff02::XX: */
|
||||
ng_ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_hdr->dst.u8[0] = 0xff;
|
||||
ipv6_hdr->dst.u8[1] = 0x02;
|
||||
ipv6_hdr->dst.u8[15] = iphc_hdr[payload_offset++];
|
||||
@ -340,7 +340,7 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
do {
|
||||
uint8_t orig_ctx_len = ctx->prefix_len;
|
||||
|
||||
ng_ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
ipv6_addr_set_unspecified(&ipv6_hdr->dst);
|
||||
|
||||
if (ctx->prefix_len > 64) {
|
||||
ctx->prefix_len = 64;
|
||||
@ -350,8 +350,8 @@ bool ng_sixlowpan_iphc_decode(ng_pktsnip_t *pkt)
|
||||
ipv6_hdr->dst.u8[1] = iphc_hdr[payload_offset++];
|
||||
ipv6_hdr->dst.u8[2] = iphc_hdr[payload_offset++];
|
||||
ipv6_hdr->dst.u8[3] = ctx->prefix_len;
|
||||
ng_ipv6_addr_init_prefix((ng_ipv6_addr_t *)ipv6_hdr->dst.u8 + 4,
|
||||
&ctx->prefix, ctx->prefix_len);
|
||||
ipv6_addr_init_prefix((ipv6_addr_t *)ipv6_hdr->dst.u8 + 4,
|
||||
&ctx->prefix, ctx->prefix_len);
|
||||
memcpy(ipv6_hdr->dst.u8 + 12, iphc_hdr + payload_offset + 2, 4);
|
||||
|
||||
payload_offset += 4;
|
||||
@ -406,11 +406,11 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
iphc_hdr[IPHC2_IDX] = 0;
|
||||
|
||||
/* check for available contexts */
|
||||
if (!ng_ipv6_addr_is_unspecified(&(ipv6_hdr->src))) {
|
||||
if (!ipv6_addr_is_unspecified(&(ipv6_hdr->src))) {
|
||||
src_ctx = ng_sixlowpan_ctx_lookup_addr(&(ipv6_hdr->src));
|
||||
}
|
||||
|
||||
if (!ng_ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
|
||||
if (!ipv6_addr_is_multicast(&ipv6_hdr->dst)) {
|
||||
dst_ctx = ng_sixlowpan_ctx_lookup_addr(&(ipv6_hdr->dst));
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
break;
|
||||
}
|
||||
|
||||
if (ng_ipv6_addr_is_unspecified(&(ipv6_hdr->src))) {
|
||||
if (ipv6_addr_is_unspecified(&(ipv6_hdr->src))) {
|
||||
iphc_hdr[IPHC2_IDX] |= IPHC_SAC_SAM_UNSPEC;
|
||||
}
|
||||
else {
|
||||
@ -502,7 +502,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
}
|
||||
}
|
||||
|
||||
if ((src_ctx != NULL) || ng_ipv6_addr_is_link_local(&(ipv6_hdr->src))) {
|
||||
if ((src_ctx != NULL) || ipv6_addr_is_link_local(&(ipv6_hdr->src))) {
|
||||
eui64_t iid;
|
||||
iid.uint64.u64 = 0;
|
||||
|
||||
@ -553,7 +553,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
addr_comp = false;
|
||||
|
||||
/* M: Multicast compression */
|
||||
if (ng_ipv6_addr_is_multicast(&(ipv6_hdr->dst))) {
|
||||
if (ipv6_addr_is_multicast(&(ipv6_hdr->dst))) {
|
||||
iphc_hdr[IPHC2_IDX] |= NG_SIXLOWPAN_IPHC2_M;
|
||||
|
||||
/* if multicast address is of format ffXX::XXXX:XXXX:XXXX */
|
||||
@ -593,7 +593,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
/* try unicast prefix based compression */
|
||||
else {
|
||||
ng_sixlowpan_ctx_t *ctx;
|
||||
ng_ipv6_addr_t unicast_prefix;
|
||||
ipv6_addr_t unicast_prefix;
|
||||
unicast_prefix.u16[0] = ipv6_hdr->dst.u16[2];
|
||||
unicast_prefix.u16[1] = ipv6_hdr->dst.u16[3];
|
||||
unicast_prefix.u16[2] = ipv6_hdr->dst.u16[4];
|
||||
@ -616,7 +616,7 @@ bool ng_sixlowpan_iphc_encode(ng_pktsnip_t *pkt)
|
||||
}
|
||||
}
|
||||
else if ((((dst_ctx != NULL) && (dst_ctx->flags_id & NG_SIXLOWPAN_CTX_FLAGS_COMP)) ||
|
||||
ng_ipv6_addr_is_link_local(&ipv6_hdr->dst)) && (netif_hdr->dst_l2addr_len > 0)) {
|
||||
ipv6_addr_is_link_local(&ipv6_hdr->dst)) && (netif_hdr->dst_l2addr_len > 0)) {
|
||||
eui64_t iid;
|
||||
|
||||
ieee802154_get_iid(&iid, ng_netif_hdr_get_dst_addr(netif_hdr),
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "net/ng_rpl/srh.h"
|
||||
|
||||
ng_ipv6_addr_t *ng_rpl_srh_next_hop(ng_rpl_srh_t *rh)
|
||||
ipv6_addr_t *ng_rpl_srh_next_hop(ng_rpl_srh_t *rh)
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct in6_addr {
|
||||
/**
|
||||
* Private RIOT-internal data, needs not to be touched by the user.
|
||||
*/
|
||||
ng_ipv6_addr_t __in6_u;
|
||||
ipv6_addr_t __in6_u;
|
||||
|
||||
/**
|
||||
* IPv6 Address represented as sequence of 8-bit numbers. Member of
|
||||
|
@ -50,7 +50,7 @@ endif
|
||||
ifneq (,$(filter ng_icmpv6_echo vtimer,$(USEMODULE)))
|
||||
SRC += sc_icmpv6_echo.c
|
||||
endif
|
||||
ifneq (,$(filter ng_zep ng_ipv6_addr,$(USEMODULE)))
|
||||
ifneq (,$(filter ng_zep ipv6_addr,$(USEMODULE)))
|
||||
SRC += sc_zep.c
|
||||
endif
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include "byteorder.h"
|
||||
#include "net/ng_icmpv6.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_netbase.h"
|
||||
@ -34,7 +34,7 @@
|
||||
static uint16_t id = 0x53;
|
||||
static uint16_t min_seq_expected = 0;
|
||||
static uint16_t max_seq_expected = 0;
|
||||
static char ipv6_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
static char ipv6_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
|
||||
static void usage(char **argv)
|
||||
{
|
||||
@ -104,7 +104,7 @@ int _handle_reply(ng_pktsnip_t *pkt, uint64_t time)
|
||||
timex_t rt = timex_from_uint64(time);
|
||||
printf("%u bytes from %s: id=%" PRIu16 " seq=%" PRIu16 " hop limit=%" PRIu8
|
||||
" time = %" PRIu32 ".%03" PRIu32 " ms\n", (unsigned) icmpv6->size,
|
||||
ng_ipv6_addr_to_str(ipv6_str, &(ipv6_hdr->src), sizeof(ipv6_str)),
|
||||
ipv6_addr_to_str(ipv6_str, &(ipv6_hdr->src), sizeof(ipv6_str)),
|
||||
byteorder_ntohs(icmpv6_hdr->id), seq, ipv6_hdr->hl,
|
||||
(rt.seconds * SEC_IN_MS) + (rt.microseconds / MS_IN_USEC),
|
||||
rt.microseconds % MS_IN_USEC);
|
||||
@ -135,7 +135,7 @@ int _icmpv6_ping(int argc, char **argv)
|
||||
size_t payload_len = 4;
|
||||
timex_t delay = { 1, 0 };
|
||||
char *addr_str;
|
||||
ng_ipv6_addr_t addr;
|
||||
ipv6_addr_t addr;
|
||||
ng_netreg_entry_t *ipv6_entry, my_entry = { NULL, NG_ICMPV6_ECHO_REP,
|
||||
thread_getpid()
|
||||
};
|
||||
@ -189,7 +189,7 @@ int _icmpv6_ping(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ng_ipv6_addr_from_str(&addr, addr_str) == NULL) || (((int)payload_len) < 0)) {
|
||||
if ((ipv6_addr_from_str(&addr, addr_str) == NULL) || (((int)payload_len) < 0)) {
|
||||
usage(argv);
|
||||
return 1;
|
||||
}
|
||||
@ -226,7 +226,7 @@ int _icmpv6_ping(int argc, char **argv)
|
||||
_set_payload(pkt->data, payload_len);
|
||||
|
||||
pkt = ng_netreg_hdr_build(NG_NETTYPE_IPV6, pkt, NULL, 0, addr.u8,
|
||||
sizeof(ng_ipv6_addr_t));
|
||||
sizeof(ipv6_addr_t));
|
||||
|
||||
if (pkt == NULL) {
|
||||
puts("error: packet buffer full");
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "kernel_types.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "thread.h"
|
||||
@ -105,7 +105,7 @@ static bool _is_iface(kernel_pid_t iface)
|
||||
|
||||
static int _ipv6_nc_list(void)
|
||||
{
|
||||
char ipv6_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
char ipv6_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
char l2addr_str[3 * MAX_L2_ADDR_LEN];
|
||||
|
||||
puts("IPv6 address if L2 address state type");
|
||||
@ -115,7 +115,7 @@ static int _ipv6_nc_list(void)
|
||||
entry != NULL;
|
||||
entry = ng_ipv6_nc_get_next(entry)) {
|
||||
printf("%-30s %2" PRIkernel_pid " %-24s ",
|
||||
ng_ipv6_addr_to_str(ipv6_str, &entry->ipv6_addr, sizeof(ipv6_str)),
|
||||
ipv6_addr_to_str(ipv6_str, &entry->ipv6_addr, sizeof(ipv6_str)),
|
||||
entry->iface,
|
||||
ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
|
||||
entry->l2_addr, entry->l2_addr_len));
|
||||
@ -130,11 +130,11 @@ static int _ipv6_nc_list(void)
|
||||
static int _ipv6_nc_add(kernel_pid_t iface, char *ipv6_addr_str,
|
||||
char *l2_addr_str)
|
||||
{
|
||||
ng_ipv6_addr_t ipv6_addr;
|
||||
ipv6_addr_t ipv6_addr;
|
||||
uint8_t l2_addr[MAX_L2_ADDR_LEN];
|
||||
size_t l2_addr_len;
|
||||
|
||||
if (ng_ipv6_addr_from_str(&ipv6_addr, ipv6_addr_str) == NULL) {
|
||||
if (ipv6_addr_from_str(&ipv6_addr, ipv6_addr_str) == NULL) {
|
||||
puts("error: unable to parse IPv6 address.");
|
||||
return 1;
|
||||
}
|
||||
@ -156,9 +156,9 @@ static int _ipv6_nc_add(kernel_pid_t iface, char *ipv6_addr_str,
|
||||
|
||||
static int _ipv6_nc_del(char *ipv6_addr_str)
|
||||
{
|
||||
ng_ipv6_addr_t ipv6_addr;
|
||||
ipv6_addr_t ipv6_addr;
|
||||
|
||||
if (ng_ipv6_addr_from_str(&ipv6_addr, ipv6_addr_str) == NULL) {
|
||||
if (ipv6_addr_from_str(&ipv6_addr, ipv6_addr_str) == NULL) {
|
||||
puts("error: unable to parse IPv6 address.");
|
||||
return 1;
|
||||
}
|
||||
@ -239,7 +239,7 @@ int _ipv6_nc_manage(int argc, char **argv)
|
||||
int _ipv6_nc_routers(int argc, char **argv)
|
||||
{
|
||||
kernel_pid_t iface = KERNEL_PID_UNDEF;
|
||||
char ipv6_str[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
char ipv6_str[IPV6_ADDR_MAX_STR_LEN];
|
||||
|
||||
if (argc > 1) {
|
||||
iface = atoi(argv[1]);
|
||||
@ -261,7 +261,7 @@ int _ipv6_nc_routers(int argc, char **argv)
|
||||
}
|
||||
|
||||
printf("%2" PRIkernel_pid " %-30s ", entry->iface,
|
||||
ng_ipv6_addr_to_str(ipv6_str, &entry->ipv6_addr, sizeof(ipv6_str)));
|
||||
ipv6_addr_to_str(ipv6_str, &entry->ipv6_addr, sizeof(ipv6_str)));
|
||||
_print_nc_state(entry);
|
||||
_print_nc_type(entry);
|
||||
puts("");
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "thread.h"
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#include "net/ng_netif.h"
|
||||
#include "net/ng_netapi.h"
|
||||
@ -177,7 +177,7 @@ static void _netif_list(kernel_pid_t dev)
|
||||
bool linebreak = false;
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(dev);
|
||||
char ipv6_addr[NG_IPV6_ADDR_MAX_STR_LEN];
|
||||
char ipv6_addr[IPV6_ADDR_MAX_STR_LEN];
|
||||
#endif
|
||||
|
||||
|
||||
@ -286,15 +286,15 @@ static void _netif_list(kernel_pid_t dev)
|
||||
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
|
||||
if (!ng_ipv6_addr_is_unspecified(&entry->addrs[i].addr)) {
|
||||
if (!ipv6_addr_is_unspecified(&entry->addrs[i].addr)) {
|
||||
printf("inet6 addr: ");
|
||||
|
||||
if (ng_ipv6_addr_to_str(ipv6_addr, &entry->addrs[i].addr,
|
||||
NG_IPV6_ADDR_MAX_STR_LEN)) {
|
||||
if (ipv6_addr_to_str(ipv6_addr, &entry->addrs[i].addr,
|
||||
IPV6_ADDR_MAX_STR_LEN)) {
|
||||
printf("%s/%" PRIu8 " scope: ", ipv6_addr,
|
||||
entry->addrs[i].prefix_len);
|
||||
|
||||
if ((ng_ipv6_addr_is_link_local(&entry->addrs[i].addr))) {
|
||||
if ((ipv6_addr_is_link_local(&entry->addrs[i].addr))) {
|
||||
printf("local");
|
||||
}
|
||||
else {
|
||||
@ -302,7 +302,7 @@ static void _netif_list(kernel_pid_t dev)
|
||||
}
|
||||
|
||||
if (entry->addrs[i].flags & NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST) {
|
||||
if (ng_ipv6_addr_is_multicast(&entry->addrs[i].addr)) {
|
||||
if (ipv6_addr_is_multicast(&entry->addrs[i].addr)) {
|
||||
printf(" [multicast]");
|
||||
}
|
||||
else {
|
||||
@ -584,7 +584,7 @@ static uint8_t _get_prefix_len(char *addr)
|
||||
*addr = '\0';
|
||||
prefix_len = atoi(addr + 1);
|
||||
|
||||
if ((prefix_len < 1) || (prefix_len > NG_IPV6_ADDR_BIT_LEN)) {
|
||||
if ((prefix_len < 1) || (prefix_len > IPV6_ADDR_BIT_LEN)) {
|
||||
prefix_len = SC_NETIF_IPV6_DEFAULT_PREFIX_LEN;
|
||||
}
|
||||
}
|
||||
@ -602,7 +602,7 @@ static int _netif_add(char *cmd_name, kernel_pid_t dev, int argc, char **argv)
|
||||
_ANYCAST
|
||||
} type = _UNICAST;
|
||||
char *addr_str = argv[0];
|
||||
ng_ipv6_addr_t addr;
|
||||
ipv6_addr_t addr;
|
||||
uint8_t prefix_len;
|
||||
|
||||
if (argc > 1) {
|
||||
@ -626,12 +626,12 @@ static int _netif_add(char *cmd_name, kernel_pid_t dev, int argc, char **argv)
|
||||
|
||||
prefix_len = _get_prefix_len(addr_str);
|
||||
|
||||
if (ng_ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("error: unable to parse IPv6 address.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((argc > 1) && (ng_ipv6_addr_is_multicast(&addr)) && (type != _MULTICAST)) {
|
||||
if ((argc > 1) && (ipv6_addr_is_multicast(&addr)) && (type != _MULTICAST)) {
|
||||
puts("error: address was not a multicast address.");
|
||||
return 1;
|
||||
}
|
||||
@ -662,9 +662,9 @@ static int _netif_add(char *cmd_name, kernel_pid_t dev, int argc, char **argv)
|
||||
static int _netif_del(kernel_pid_t dev, char *addr_str)
|
||||
{
|
||||
#ifdef MODULE_NG_IPV6_NETIF
|
||||
ng_ipv6_addr_t addr;
|
||||
ipv6_addr_t addr;
|
||||
|
||||
if (ng_ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
if (ipv6_addr_from_str(&addr, addr_str) == NULL) {
|
||||
puts("error: unable to parse IPv6 address.");
|
||||
return 1;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/netif.h"
|
||||
#include "net/ng_nomac.h"
|
||||
#include "net/ng_zep.h"
|
||||
@ -30,7 +30,7 @@ int _zep_init(int argc, char **argv)
|
||||
{
|
||||
uint16_t src_port = NG_ZEP_DEFAULT_PORT;
|
||||
uint16_t dst_port = NG_ZEP_DEFAULT_PORT;
|
||||
ng_ipv6_addr_t dst_addr;
|
||||
ipv6_addr_t dst_addr;
|
||||
int res;
|
||||
|
||||
if (argc < 2) {
|
||||
@ -46,7 +46,7 @@ int _zep_init(int argc, char **argv)
|
||||
dst_port = (uint16_t)atoi(argv[3]);
|
||||
}
|
||||
|
||||
ng_ipv6_addr_from_str(&dst_addr, argv[1]);
|
||||
ipv6_addr_from_str(&dst_addr, argv[1]);
|
||||
|
||||
if ((res = ng_zep_init(&zep, src_port, &dst_addr, dst_port)) < 0) {
|
||||
switch (res) {
|
||||
|
@ -111,7 +111,7 @@ extern int _ipv6_nc_routers(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_NG_ZEP
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
extern int _zep_init(int argc, char **argv);
|
||||
#endif
|
||||
#endif
|
||||
@ -187,7 +187,7 @@ const shell_command_t _shell_command_list[] = {
|
||||
{"routers", "IPv6 default router list", _ipv6_nc_routers },
|
||||
#endif
|
||||
#ifdef MODULE_NG_ZEP
|
||||
#ifdef MODULE_NG_IPV6_ADDR
|
||||
#ifdef MODULE_IPV6_ADDR
|
||||
{"zep_init", "initializes ZEP (Zigbee Encapsulation Protocol)", _zep_init },
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1 +1 @@
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Unittests for the ``ng_ipv6_addr`` module
|
||||
* @brief Unittests for the ``ipv6_addr`` module
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/hdr.h"
|
||||
#include "net/ng_pktbuf.h"
|
||||
#include "net/protnum.h"
|
||||
@ -301,39 +301,39 @@ static void test_ipv6_hdr_inet_csum__initial_sum_0(void)
|
||||
|
||||
static void test_ipv6_hdr_build__wrong_src_len(void)
|
||||
{
|
||||
ng_ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ng_ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
|
||||
ng_pktbuf_init();
|
||||
TEST_ASSERT_NULL(ng_ipv6_hdr_build(NULL, (uint8_t *)&src,
|
||||
sizeof(ng_ipv6_addr_t) + TEST_UINT8,
|
||||
sizeof(ipv6_addr_t) + TEST_UINT8,
|
||||
(uint8_t *)&dst,
|
||||
sizeof(ng_ipv6_addr_t)));
|
||||
sizeof(ipv6_addr_t)));
|
||||
TEST_ASSERT(ng_pktbuf_is_empty());
|
||||
}
|
||||
|
||||
static void test_ipv6_hdr_build__wrong_dst_len(void)
|
||||
{
|
||||
ng_ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ng_ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
|
||||
ng_pktbuf_init();
|
||||
TEST_ASSERT_NULL(ng_ipv6_hdr_build(NULL, (uint8_t *)&src,
|
||||
sizeof(ng_ipv6_addr_t),
|
||||
sizeof(ipv6_addr_t),
|
||||
(uint8_t *)&dst,
|
||||
sizeof(ng_ipv6_addr_t) + TEST_UINT8));
|
||||
sizeof(ipv6_addr_t) + TEST_UINT8));
|
||||
TEST_ASSERT(ng_pktbuf_is_empty());
|
||||
}
|
||||
|
||||
static void test_ipv6_hdr_build__src_NULL(void)
|
||||
{
|
||||
ng_ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ng_pktsnip_t *pkt;
|
||||
ng_ipv6_hdr_t *hdr;
|
||||
|
||||
ng_pktbuf_init();
|
||||
TEST_ASSERT_NOT_NULL((pkt = ng_ipv6_hdr_build(NULL, NULL, 0, (uint8_t *)&dst,
|
||||
sizeof(ng_ipv6_addr_t))));
|
||||
sizeof(ipv6_addr_t))));
|
||||
hdr = pkt->data;
|
||||
TEST_ASSERT_NOT_NULL(hdr);
|
||||
TEST_ASSERT(ng_ipv6_hdr_is(hdr));
|
||||
@ -341,19 +341,19 @@ static void test_ipv6_hdr_build__src_NULL(void)
|
||||
TEST_ASSERT_EQUAL_INT(0, ng_ipv6_hdr_get_fl(hdr));
|
||||
TEST_ASSERT_EQUAL_INT(PROTNUM_RESERVED, hdr->nh);
|
||||
TEST_ASSERT_EQUAL_INT(0, hdr->hl);
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&dst, &hdr->dst));
|
||||
TEST_ASSERT(ipv6_addr_equal(&dst, &hdr->dst));
|
||||
TEST_ASSERT(!ng_pktbuf_is_empty());
|
||||
}
|
||||
|
||||
static void test_ipv6_hdr_build__dst_NULL(void)
|
||||
{
|
||||
ng_ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ng_pktsnip_t *pkt;
|
||||
ng_ipv6_hdr_t *hdr;
|
||||
|
||||
ng_pktbuf_init();
|
||||
TEST_ASSERT_NOT_NULL((pkt = ng_ipv6_hdr_build(NULL, (uint8_t *)&src,
|
||||
sizeof(ng_ipv6_addr_t),
|
||||
sizeof(ipv6_addr_t),
|
||||
NULL, 0)));
|
||||
hdr = pkt->data;
|
||||
TEST_ASSERT_NOT_NULL(hdr);
|
||||
@ -362,22 +362,22 @@ static void test_ipv6_hdr_build__dst_NULL(void)
|
||||
TEST_ASSERT_EQUAL_INT(0, ng_ipv6_hdr_get_fl(hdr));
|
||||
TEST_ASSERT_EQUAL_INT(PROTNUM_RESERVED, hdr->nh);
|
||||
TEST_ASSERT_EQUAL_INT(0, hdr->hl);
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&src, &hdr->src));
|
||||
TEST_ASSERT(ipv6_addr_equal(&src, &hdr->src));
|
||||
TEST_ASSERT(!ng_pktbuf_is_empty());
|
||||
}
|
||||
|
||||
static void test_ipv6_hdr_build__complete(void)
|
||||
{
|
||||
ng_ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ng_ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ipv6_addr_t src = DEFAULT_TEST_SRC;
|
||||
ipv6_addr_t dst = DEFAULT_TEST_DST;
|
||||
ng_pktsnip_t *pkt;
|
||||
ng_ipv6_hdr_t *hdr;
|
||||
|
||||
ng_pktbuf_init();
|
||||
TEST_ASSERT_NOT_NULL((pkt = ng_ipv6_hdr_build(NULL, (uint8_t *)&src,
|
||||
sizeof(ng_ipv6_addr_t),
|
||||
sizeof(ipv6_addr_t),
|
||||
(uint8_t *)&dst,
|
||||
sizeof(ng_ipv6_addr_t))));
|
||||
sizeof(ipv6_addr_t))));
|
||||
hdr = pkt->data;
|
||||
TEST_ASSERT_NOT_NULL(hdr);
|
||||
TEST_ASSERT(ng_ipv6_hdr_is(hdr));
|
||||
@ -385,8 +385,8 @@ static void test_ipv6_hdr_build__complete(void)
|
||||
TEST_ASSERT_EQUAL_INT(0, ng_ipv6_hdr_get_fl(hdr));
|
||||
TEST_ASSERT_EQUAL_INT(PROTNUM_RESERVED, hdr->nh);
|
||||
TEST_ASSERT_EQUAL_INT(0, hdr->hl);
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&src, &hdr->src));
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&dst, &hdr->dst));
|
||||
TEST_ASSERT(ipv6_addr_equal(&src, &hdr->src));
|
||||
TEST_ASSERT(ipv6_addr_equal(&dst, &hdr->dst));
|
||||
TEST_ASSERT(!ng_pktbuf_is_empty());
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_ipv6/nc.h"
|
||||
|
||||
#include "unittests-constants.h"
|
||||
@ -54,7 +54,7 @@ static void set_up(void)
|
||||
|
||||
static void test_ipv6_nc_add__address_registered(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry1, *entry2;
|
||||
|
||||
TEST_ASSERT_NOT_NULL((entry1 = ng_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr,
|
||||
@ -74,7 +74,7 @@ static void test_ipv6_nc_add__address_NULL(void)
|
||||
|
||||
static void test_ipv6_nc_add__iface_KERNEL_PID_UNDEF(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_nc_add(KERNEL_PID_UNDEF, &addr, TEST_STRING4,
|
||||
sizeof(TEST_STRING4), 0));
|
||||
@ -82,7 +82,7 @@ static void test_ipv6_nc_add__iface_KERNEL_PID_UNDEF(void)
|
||||
|
||||
static void test_ipv6_nc_add__addr_unspecified(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
|
||||
|
||||
TEST_ASSERT_NULL(ng_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING4,
|
||||
sizeof(TEST_STRING4), 0));
|
||||
@ -90,7 +90,7 @@ static void test_ipv6_nc_add__addr_unspecified(void)
|
||||
|
||||
static void test_ipv6_nc_add__l2addr_too_long(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
TEST_ASSERT_NULL(ng_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING4,
|
||||
NG_IPV6_NC_L2_ADDR_MAX + TEST_UINT8, 0));
|
||||
@ -98,7 +98,7 @@ static void test_ipv6_nc_add__l2addr_too_long(void)
|
||||
|
||||
static void test_ipv6_nc_add__full(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
for (int i = 0; i < NG_IPV6_NC_SIZE; i++) {
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr, TEST_STRING4,
|
||||
@ -112,7 +112,7 @@ static void test_ipv6_nc_add__full(void)
|
||||
|
||||
static void test_ipv6_nc_add__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry1, *entry2;
|
||||
|
||||
TEST_ASSERT_NOT_NULL((entry1 = ng_ipv6_nc_add(DEFAULT_TEST_NETIF, &addr,
|
||||
@ -125,8 +125,8 @@ static void test_ipv6_nc_add__success(void)
|
||||
|
||||
static void test_ipv6_nc_add__address_update_despite_free_entry(void)
|
||||
{
|
||||
ng_ipv6_addr_t default_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t default_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry1, *entry2;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_nc_add(OTHER_TEST_NETIF, &other_addr,
|
||||
@ -146,7 +146,7 @@ static void test_ipv6_nc_add__address_update_despite_free_entry(void)
|
||||
|
||||
static void test_ipv6_nc_remove__no_entry_pid(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
ng_ipv6_nc_remove(OTHER_TEST_NETIF, &addr);
|
||||
@ -156,8 +156,8 @@ static void test_ipv6_nc_remove__no_entry_pid(void)
|
||||
|
||||
static void test_ipv6_nc_remove__no_entry_addr1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t exp_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t exp_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
ng_ipv6_nc_remove(DEFAULT_TEST_NETIF, &addr);
|
||||
@ -167,8 +167,8 @@ static void test_ipv6_nc_remove__no_entry_addr1(void)
|
||||
|
||||
static void test_ipv6_nc_remove__no_entry_addr2(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ng_ipv6_addr_t exp_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t exp_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
ng_ipv6_nc_remove(DEFAULT_TEST_NETIF, &addr);
|
||||
@ -178,7 +178,7 @@ static void test_ipv6_nc_remove__no_entry_addr2(void)
|
||||
|
||||
static void test_ipv6_nc_remove__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_nc_get(DEFAULT_TEST_NETIF, &addr));
|
||||
@ -188,14 +188,14 @@ static void test_ipv6_nc_remove__success(void)
|
||||
|
||||
static void test_ipv6_nc_get__empty(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
TEST_ASSERT_NULL(ng_ipv6_nc_get(DEFAULT_TEST_NETIF, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_nc_get__different_if(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
|
||||
@ -204,7 +204,7 @@ static void test_ipv6_nc_get__different_if(void)
|
||||
|
||||
static void test_ipv6_nc_get__different_addr(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
|
||||
@ -213,14 +213,14 @@ static void test_ipv6_nc_get__different_addr(void)
|
||||
|
||||
static void test_ipv6_nc_get__success_if_local(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((entry = ng_ipv6_nc_get(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, entry->iface);
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&(entry->ipv6_addr), &addr));
|
||||
TEST_ASSERT(ipv6_addr_equal(&(entry->ipv6_addr), &addr));
|
||||
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, (char *)entry->l2_addr);
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING4), entry->l2_addr_len);
|
||||
TEST_ASSERT_EQUAL_INT(0, entry->flags);
|
||||
@ -228,14 +228,14 @@ static void test_ipv6_nc_get__success_if_local(void)
|
||||
|
||||
static void test_ipv6_nc_get__success_if_global(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((entry = ng_ipv6_nc_get(KERNEL_PID_UNDEF, &addr)));
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, entry->iface);
|
||||
TEST_ASSERT(ng_ipv6_addr_equal(&(entry->ipv6_addr), &addr));
|
||||
TEST_ASSERT(ipv6_addr_equal(&(entry->ipv6_addr), &addr));
|
||||
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, (char *)entry->l2_addr);
|
||||
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING4), entry->l2_addr_len);
|
||||
TEST_ASSERT_EQUAL_INT(0, entry->flags);
|
||||
@ -258,7 +258,7 @@ static void test_ipv6_nc_get_next__1_entry(void)
|
||||
|
||||
static void test_ipv6_nc_get_next__2_entries(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
@ -273,8 +273,8 @@ static void test_ipv6_nc_get_next__2_entries(void)
|
||||
|
||||
static void test_ipv6_nc_get_next__holey(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr1 = OTHER_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t addr2 = THIRD_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr1 = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr2 = THIRD_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL, *exp_entry = NULL;
|
||||
|
||||
/* adds DEFAULT_TEST_IPV6_ADDR and OTHER_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
@ -327,7 +327,7 @@ static void test_ipv6_nc_get_next_router__second_entry(void)
|
||||
|
||||
static void test_ipv6_nc_is_reachable__incomplete(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
@ -339,7 +339,7 @@ static void test_ipv6_nc_is_reachable__incomplete(void)
|
||||
|
||||
static void test_ipv6_nc_is_reachable__reachable(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
test_ipv6_nc_add__success(); /* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF */
|
||||
@ -351,7 +351,7 @@ static void test_ipv6_nc_is_reachable__reachable(void)
|
||||
|
||||
static void test_ipv6_nc_still_reachable__incomplete(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
/* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF and sets flags to
|
||||
@ -366,7 +366,7 @@ static void test_ipv6_nc_still_reachable__incomplete(void)
|
||||
|
||||
static void test_ipv6_nc_still_reachable__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_nc_t *entry = NULL;
|
||||
|
||||
/* adds DEFAULT_TEST_IPV6_ADDR to DEFAULT_TEST_NETIF and sets flags to
|
||||
|
@ -1,4 +1,4 @@
|
||||
USEMODULE += ng_ipv6_addr
|
||||
USEMODULE += ipv6_addr
|
||||
USEMODULE += ng_ipv6_netif
|
||||
USEMODULE += ng_netif
|
||||
|
||||
|
@ -83,7 +83,7 @@ static void test_netif_add__success_with_ipv6(void)
|
||||
kernel_pid_t pids[NG_NETIF_NUMOF];
|
||||
size_t pid_num;
|
||||
ng_ipv6_netif_t *entry;
|
||||
ng_ipv6_addr_t exp_addr = NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
ipv6_addr_t exp_addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
|
||||
ng_netif_add(DEFAULT_TEST_NETIF);
|
||||
|
||||
@ -137,7 +137,7 @@ static void test_ipv6_netif_get__empty(void)
|
||||
|
||||
static void test_ipv6_netif_add_addr__no_iface1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
TEST_ASSERT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0));
|
||||
}
|
||||
@ -156,7 +156,7 @@ static void test_ipv6_netif_add_addr__addr_NULL(void)
|
||||
|
||||
static void test_ipv6_netif_add_addr__addr_unspecified(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t addr = IPV6_ADDR_UNSPECIFIED;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -165,11 +165,11 @@ static void test_ipv6_netif_add_addr__addr_unspecified(void)
|
||||
|
||||
static void test_ipv6_netif_add_addr__full(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR, *res = &addr;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR, *res = &addr;
|
||||
int i;
|
||||
|
||||
/* make link local to avoid automatic link local adding */
|
||||
ng_ipv6_addr_set_link_local_prefix(&addr);
|
||||
ipv6_addr_set_link_local_prefix(&addr);
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -180,7 +180,7 @@ static void test_ipv6_netif_add_addr__full(void)
|
||||
|
||||
static void test_ipv6_netif_add_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -190,11 +190,11 @@ static void test_ipv6_netif_add_addr__success(void)
|
||||
static void test_ipv6_netif_add_addr__despite_free_entry(void)
|
||||
{
|
||||
/* Tests for possible duplicates as described in http://github.com/RIOT-OS/RIOT/issues/2965 */
|
||||
ng_ipv6_addr_t *entry_1;
|
||||
ng_ipv6_addr_t *entry_2;
|
||||
ipv6_addr_t *entry_1;
|
||||
ipv6_addr_t *entry_2;
|
||||
|
||||
ng_ipv6_addr_t default_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t ll_addr;
|
||||
ipv6_addr_t default_addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t ll_addr;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -208,7 +208,7 @@ static void test_ipv6_netif_add_addr__despite_free_entry(void)
|
||||
/* create and re-add corresponding lla and check that it hasn't taken
|
||||
* the old place of default_addr*/
|
||||
ll_addr.u64[1] = default_addr.u64[1];
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr);
|
||||
TEST_ASSERT_NOT_NULL((entry_2 = ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr, DEFAULT_TEST_PREFIX_LEN, 0)));
|
||||
|
||||
TEST_ASSERT(entry_1 != entry_2);
|
||||
@ -216,8 +216,8 @@ static void test_ipv6_netif_add_addr__despite_free_entry(void)
|
||||
|
||||
static void test_ipv6_netif_remove_addr__not_allocated(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t other_addr = OTHER_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -230,7 +230,7 @@ static void test_ipv6_netif_remove_addr__not_allocated(void)
|
||||
|
||||
static void test_ipv6_netif_remove_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -242,7 +242,7 @@ static void test_ipv6_netif_remove_addr__success(void)
|
||||
|
||||
static void test_ipv6_netif_reset_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -254,8 +254,8 @@ static void test_ipv6_netif_reset_addr__success(void)
|
||||
|
||||
static void test_ipv6_netif_find_by_addr__empty(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(KERNEL_PID_UNDEF, ng_ipv6_netif_find_by_addr(&out, &addr));
|
||||
TEST_ASSERT_NULL(out);
|
||||
@ -263,8 +263,8 @@ static void test_ipv6_netif_find_by_addr__empty(void)
|
||||
|
||||
static void test_ipv6_netif_find_by_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -272,19 +272,19 @@ static void test_ipv6_netif_find_by_addr__success(void)
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, ng_ipv6_netif_find_by_addr(&out, &addr));
|
||||
TEST_ASSERT_NOT_NULL(out);
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_addr_equal(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(true, ipv6_addr_equal(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_addr__no_iface(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
TEST_ASSERT_NULL(ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_addr__wrong_iface(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -294,7 +294,7 @@ static void test_ipv6_netif_find_addr__wrong_iface(void)
|
||||
|
||||
static void test_ipv6_netif_find_addr__wrong_addr(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr = OTHER_TEST_IPV6_ADDR;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -304,26 +304,26 @@ static void test_ipv6_netif_find_addr__wrong_addr(void)
|
||||
|
||||
static void test_ipv6_netif_find_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_addr_equal(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(true, ipv6_addr_equal(out, &addr));
|
||||
|
||||
/* also test for link local address */
|
||||
ng_ipv6_addr_set_link_local_prefix(&addr);
|
||||
ipv6_addr_set_link_local_prefix(&addr);
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_addr_equal(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(true, ipv6_addr_equal(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_by_prefix__success1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX23;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX23;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -331,13 +331,13 @@ static void test_ipv6_netif_find_by_prefix__success1(void)
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, ng_ipv6_netif_find_by_prefix(&out, &addr));
|
||||
TEST_ASSERT_NOT_NULL(out);
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(23, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(23, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_by_prefix__success2(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX18;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX18;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -345,13 +345,13 @@ static void test_ipv6_netif_find_by_prefix__success2(void)
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, ng_ipv6_netif_find_by_prefix(&out, &addr));
|
||||
TEST_ASSERT_NOT_NULL(out);
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(18, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(18, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_by_prefix__success3(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX64;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX64;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -359,60 +359,60 @@ static void test_ipv6_netif_find_by_prefix__success3(void)
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_NETIF, ng_ipv6_netif_find_by_prefix(&out, &addr));
|
||||
TEST_ASSERT_NOT_NULL(out);
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(64, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(64, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_match_prefix__success1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX23;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX23;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_match_prefix(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(23, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(23, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_match_prefix__success2(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX18;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX18;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_match_prefix(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(18, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(18, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_match_prefix__success3(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX64;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_PREFIX64;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_match_prefix(DEFAULT_TEST_NETIF, &addr)));
|
||||
TEST_ASSERT(out != &addr);
|
||||
TEST_ASSERT_EQUAL_INT(64, ng_ipv6_addr_match_prefix(out, &addr));
|
||||
TEST_ASSERT_EQUAL_INT(64, ipv6_addr_match_prefix(out, &addr));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_best_src_addr__no_unicast(void)
|
||||
{
|
||||
ng_ipv6_addr_t ll_addr1 = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ng_ipv6_addr_t ll_addr2 = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ng_ipv6_addr_t mc_addr = NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
ipv6_addr_t ll_addr1 = IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t ll_addr2 = IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t mc_addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
|
||||
ll_addr1.u8[15] = 1;
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr1);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr1);
|
||||
ll_addr2.u8[15] = 2;
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr2);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr2);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(126, ng_ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
|
||||
TEST_ASSERT_EQUAL_INT(126, ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr, DEFAULT_TEST_PREFIX_LEN,
|
||||
@ -425,17 +425,17 @@ static void test_ipv6_netif_find_best_src_addr__no_unicast(void)
|
||||
|
||||
static void test_ipv6_netif_find_best_src_addr__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t ll_addr1 = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ng_ipv6_addr_t ll_addr2 = NG_IPV6_ADDR_UNSPECIFIED;
|
||||
ng_ipv6_addr_t mc_addr = NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t ll_addr1 = IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t ll_addr2 = IPV6_ADDR_UNSPECIFIED;
|
||||
ipv6_addr_t mc_addr = IPV6_ADDR_ALL_NODES_LINK_LOCAL;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
ll_addr1.u8[15] = 1;
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr1);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr1);
|
||||
ll_addr2.u8[15] = 2;
|
||||
ng_ipv6_addr_set_link_local_prefix(&ll_addr2);
|
||||
ipv6_addr_set_link_local_prefix(&ll_addr2);
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(126, ng_ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
|
||||
TEST_ASSERT_EQUAL_INT(126, ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr, DEFAULT_TEST_PREFIX_LEN,
|
||||
@ -446,28 +446,28 @@ static void test_ipv6_netif_find_best_src_addr__success(void)
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_best_src_addr(DEFAULT_TEST_NETIF, &ll_addr2)));
|
||||
TEST_ASSERT(out != &ll_addr1);
|
||||
TEST_ASSERT(out != &ll_addr2);
|
||||
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_addr_equal(out, &ll_addr1));
|
||||
TEST_ASSERT_EQUAL_INT(true, ipv6_addr_equal(out, &ll_addr1));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_best_src_addr__multicast_input(void)
|
||||
{
|
||||
ng_ipv6_addr_t mc_addr = NG_IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t mc_addr = IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
/* Adds DEFAULT_TEST_NETIF as interface and to it fe80::1, fe80::2 and ff02::1 */
|
||||
test_ipv6_netif_find_best_src_addr__success();
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_best_src_addr(DEFAULT_TEST_NETIF, &mc_addr)));
|
||||
TEST_ASSERT_EQUAL_INT(false, ng_ipv6_addr_equal(&mc_addr, out));
|
||||
TEST_ASSERT_EQUAL_INT(false, ng_ipv6_addr_is_unspecified(out));
|
||||
TEST_ASSERT_EQUAL_INT(false, ipv6_addr_equal(&mc_addr, out));
|
||||
TEST_ASSERT_EQUAL_INT(false, ipv6_addr_is_unspecified(out));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_find_best_src_addr__other_subnet(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr1 = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t addr2 = OTHER_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr1 = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t addr2 = OTHER_TEST_IPV6_ADDR;
|
||||
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr1, DEFAULT_TEST_PREFIX_LEN,
|
||||
@ -475,13 +475,13 @@ static void test_ipv6_netif_find_best_src_addr__other_subnet(void)
|
||||
|
||||
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_best_src_addr(DEFAULT_TEST_NETIF, &addr2)));
|
||||
TEST_ASSERT(out != &addr1);
|
||||
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_addr_equal(out, &addr1));
|
||||
TEST_ASSERT_EQUAL_INT(true, ipv6_addr_equal(out, &addr1));
|
||||
}
|
||||
|
||||
static void test_ipv6_netif_addr_is_non_unicast__unicast(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add_addr__success(); /* adds DEFAULT_TEST_IPV6_ADDR to
|
||||
* DEFAULT_TEST_NETIF */
|
||||
@ -492,8 +492,8 @@ static void test_ipv6_netif_addr_is_non_unicast__unicast(void)
|
||||
|
||||
static void test_ipv6_netif_addr_is_non_unicast__anycast(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -506,8 +506,8 @@ static void test_ipv6_netif_addr_is_non_unicast__anycast(void)
|
||||
|
||||
static void test_ipv6_netif_addr_is_non_unicast__multicast1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
@ -519,8 +519,8 @@ static void test_ipv6_netif_addr_is_non_unicast__multicast1(void)
|
||||
|
||||
static void test_ipv6_netif_addr_is_non_unicast__multicast2(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = NG_IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ng_ipv6_addr_t *out = NULL;
|
||||
ipv6_addr_t addr = IPV6_ADDR_ALL_ROUTERS_LINK_LOCAL;
|
||||
ipv6_addr_t *out = NULL;
|
||||
|
||||
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "embUnit.h"
|
||||
|
||||
#include "net/ng_ipv6/addr.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
#include "net/ng_sixlowpan/ctx.h"
|
||||
|
||||
#include "unittests-constants.h"
|
||||
@ -50,7 +50,7 @@ static void tear_down(void)
|
||||
|
||||
static void test_sixlowpan_ctx_update__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(ng_sixlowpan_ctx_update(DEFAULT_TEST_ID, &addr,
|
||||
DEFAULT_TEST_PREFIX_LEN,
|
||||
@ -60,7 +60,7 @@ static void test_sixlowpan_ctx_update__success(void)
|
||||
|
||||
static void test_sixlowpan_ctx_update__ltime0(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
TEST_ASSERT_NOT_NULL(ng_sixlowpan_ctx_update(DEFAULT_TEST_ID, &addr,
|
||||
DEFAULT_TEST_PREFIX_LEN,
|
||||
@ -71,7 +71,7 @@ static void test_sixlowpan_ctx_update__ltime0(void)
|
||||
|
||||
static void test_sixlowpan_ctx_update__wrong_id1(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
test_sixlowpan_ctx_update__success();
|
||||
@ -90,7 +90,7 @@ static void test_sixlowpan_ctx_update__wrong_id1(void)
|
||||
|
||||
static void test_sixlowpan_ctx_update__wrong_id2(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
test_sixlowpan_ctx_update__success();
|
||||
@ -109,7 +109,7 @@ static void test_sixlowpan_ctx_update__wrong_id2(void)
|
||||
|
||||
static void test_sixlowpan_ctx_update__wrong_prefix_len(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
TEST_ASSERT_NULL(ng_sixlowpan_ctx_update(DEFAULT_TEST_ID, &addr,
|
||||
0, TEST_UINT16, true));
|
||||
@ -118,14 +118,14 @@ static void test_sixlowpan_ctx_update__wrong_prefix_len(void)
|
||||
|
||||
static void test_sixlowpan_ctx_lookup_addr__empty(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
TEST_ASSERT_NULL(ng_sixlowpan_ctx_lookup_addr(&addr));
|
||||
}
|
||||
|
||||
static void test_sixlowpan_ctx_lookup_addr__same_addr(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ng_sixlowpan_ctx_t *ctx;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
@ -134,13 +134,13 @@ static void test_sixlowpan_ctx_lookup_addr__same_addr(void)
|
||||
TEST_ASSERT_EQUAL_INT(NG_SIXLOWPAN_CTX_FLAGS_COMP | DEFAULT_TEST_ID, ctx->flags_id);
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_PREFIX_LEN, ctx->prefix_len);
|
||||
TEST_ASSERT(TEST_UINT16 >= ctx->ltime);
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ng_ipv6_addr_match_prefix(&addr, &ctx->prefix));
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ipv6_addr_match_prefix(&addr, &ctx->prefix));
|
||||
}
|
||||
|
||||
static void test_sixlowpan_ctx_lookup_addr__other_addr_same_prefix(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr1 = DEFAULT_TEST_PREFIX;
|
||||
ng_ipv6_addr_t addr2 = OTHER_TEST_PREFIX;
|
||||
ipv6_addr_t addr1 = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr2 = OTHER_TEST_PREFIX;
|
||||
ng_sixlowpan_ctx_t *ctx;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
@ -149,12 +149,12 @@ static void test_sixlowpan_ctx_lookup_addr__other_addr_same_prefix(void)
|
||||
TEST_ASSERT_EQUAL_INT(NG_SIXLOWPAN_CTX_FLAGS_COMP | DEFAULT_TEST_ID, ctx->flags_id);
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_PREFIX_LEN, ctx->prefix_len);
|
||||
TEST_ASSERT(TEST_UINT16 >= ctx->ltime);
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ng_ipv6_addr_match_prefix(&addr1, &ctx->prefix));
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ipv6_addr_match_prefix(&addr1, &ctx->prefix));
|
||||
}
|
||||
|
||||
static void test_sixlowpan_ctx_lookup_addr__other_addr_other_prefix(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = WRONG_TEST_PREFIX;
|
||||
ipv6_addr_t addr = WRONG_TEST_PREFIX;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
test_sixlowpan_ctx_update__success();
|
||||
@ -175,7 +175,7 @@ static void test_sixlowpan_ctx_lookup_id__wrong_id(void)
|
||||
|
||||
static void test_sixlowpan_ctx_lookup_id__success(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ng_sixlowpan_ctx_t *ctx;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
@ -184,12 +184,12 @@ static void test_sixlowpan_ctx_lookup_id__success(void)
|
||||
TEST_ASSERT_EQUAL_INT(NG_SIXLOWPAN_CTX_FLAGS_COMP | DEFAULT_TEST_ID, ctx->flags_id);
|
||||
TEST_ASSERT_EQUAL_INT(DEFAULT_TEST_PREFIX_LEN, ctx->prefix_len);
|
||||
TEST_ASSERT(TEST_UINT16 >= ctx->ltime);
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ng_ipv6_addr_match_prefix(&addr, &ctx->prefix));
|
||||
TEST_ASSERT(DEFAULT_TEST_PREFIX_LEN >= ipv6_addr_match_prefix(&addr, &ctx->prefix));
|
||||
}
|
||||
|
||||
static void test_sixlowpan_ctx_remove(void)
|
||||
{
|
||||
ng_ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
ipv6_addr_t addr = DEFAULT_TEST_PREFIX;
|
||||
|
||||
/* add context DEFAULT_TEST_PREFIX to DEFAULT_TEST_ID */
|
||||
test_sixlowpan_ctx_update__success();
|
||||
|
Loading…
Reference in New Issue
Block a user