diff --git a/sys/include/net/ng_ipv6/netif.h b/sys/include/net/ng_ipv6/netif.h
index 79c4749e51..5acbc6c55c 100644
--- a/sys/include/net/ng_ipv6/netif.h
+++ b/sys/include/net/ng_ipv6/netif.h
@@ -29,6 +29,7 @@
#include "kernel_types.h"
#include "mutex.h"
#include "net/ng_ipv6/addr.h"
+#include "vtimer.h"
#ifdef __cplusplus
extern "C" {
@@ -79,6 +80,24 @@ extern "C" {
*/
#define NG_IPV6_NETIF_ADDR_FLAGS_UNICAST (0x00) /**< unicast address */
#define NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST (0x01) /**< non-unicast address */
+
+/**
+ * @brief A prefix information option that propagates the prefix of this
+ * address should set the autonomous flag.
+ * @see
+ * RFC 4861, section 6.2.1
+ *
+ */
+#define NG_IPV6_NETIF_ADDR_FLAGS_NDP_AUTO (0x40)
+
+/**
+ * @brief A prefix information option that propagates the prefix of this
+ * address should set the on-link flag.
+ * @see
+ * RFC 4861, section 6.2.1
+ *
+ */
+#define NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK (0x80)
/**
* @}
*/
@@ -87,7 +106,45 @@ extern "C" {
* @{
* @name Flags for the interfaces
*/
-#define NG_IPV6_NETIF_FLAGS_SIXLOWPAN (0x01) /**< interface is 6LoWPAN interface */
+/**
+ * @brief Interface is 6LoWPAN interface.
+ */
+#define NG_IPV6_NETIF_FLAGS_SIXLOWPAN (0x0001)
+
+/**
+ * @brief Flag to indicate that routing is enabled on the interface.
+ */
+#define NG_IPV6_NETIF_FLAGS_ROUTER (0x0002)
+
+/**
+ * @brief Flag to indicate that the interface sends periodic router
+ * advertisements and in response to router solicitations.
+ */
+#define NG_IPV6_NETIF_FLAGS_RTR_ADV (0x0004)
+
+/**
+ * @brief Flag to indicate that ng_ipv6_netif_t::mtu shall be propagated
+ * with the MTU options in router advertisements.
+ */
+#define NG_IPV6_NETIF_FLAGS_ADV_MTU (0x0008)
+
+/**
+ * @brief Flag to indicate that ng_ipv6_netif_t::cur_hl shall be propagated
+ * in router advertisements.
+ */
+#define NG_IPV6_NETIF_FLAGS_ADV_CUR_HL (0x0010)
+
+/**
+ * @brief Flag to indicate that the interface has other address
+ * configuration.
+ */
+#define NG_IPV6_NETIF_FLAGS_OTHER_CONF (0x4000)
+
+/**
+ * @brief Flag to indicate that the interface has managed address
+ * configuration (e.g. via DHCPv6).
+ */
+#define NG_IPV6_NETIF_FLAGS_MANAGED (0x8000)
/**
* @}
*/
@@ -99,6 +156,32 @@ typedef struct {
ng_ipv6_addr_t addr; /**< The address data */
uint8_t flags; /**< flags */
uint8_t prefix_len; /**< length of the prefix of the address */
+ /**
+ * @{
+ * @name Neigbour discovery variables for prefixes
+ * @see
+ * RFC 4861, section 6.2.1
+ *
+ */
+ /**
+ * @brief The time in seconds this address is valid. If it is UINT32_MAX
+ * the lifetime is infinite.
+ */
+ uint32_t valid;
+
+ /**
+ * @brief The length of time that this address remains preferred.
+ * If it is UINT32_MAX the lifetime is infinite.
+ * It **must** be < ng_ipv6_netif_addr_t::valid.
+ */
+ uint32_t preferred;
+ /**
+ * @brief Validity timeout timer.
+ */
+ vtimer_t valid_timeout;
+ /**
+ * @}
+ */
} ng_ipv6_netif_addr_t;
/**
@@ -111,7 +194,7 @@ typedef struct {
kernel_pid_t pid; /**< PID of the interface */
uint16_t mtu; /**< Maximum Transmission Unit (MTU) of the interface */
uint8_t cur_hl; /**< current hop limit for the interface */
- uint8_t flags; /**< flags for 6LoWPAN and Neighbor Discovery */
+ uint16_t flags; /**< flags for 6LoWPAN and Neighbor Discovery */
} ng_ipv6_netif_t;
/**
@@ -154,28 +237,29 @@ ng_ipv6_netif_t *ng_ipv6_netif_get(kernel_pid_t pid);
* @param[in] addr An address you want to add to the interface.
* @param[in] prefix_len Length of the prefix of the address.
* Must be between 1 and 128.
- * @param[in] anycast If @p addr should be an anycast address, @p anycast
- * must be true. Otherwise set it false.
- * If @p addr is a multicast address, @p anycast will be
- * ignored.
+ * @param[in] flags Flags for the address entry
+ * If @p addr should be an anycast address, @p flags
+ * must have @ref NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST
+ * set. Otherwise leave it unset.
+ * If @p addr is a multicast address, the status of
+ * @ref NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST will be
+ * ignored and set in either case.
*
* @see
* RFC 4291, section 2.6
*
*
- * @return 0, on success.
- * @return -EINVAL, if @p addr is NULL or unspecified address or if
- * @p prefix length was < 1 or > 128.
- * @return -ENOENT, if @p pid is no interface.
- * @return -ENOMEM, if there is no space left to store @p addr.
+ * @return The address on the interface, on success.
+ * @return NULL, on failure
*/
-int ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *addr,
- uint8_t prefix_len, bool anycast);
+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);
/**
* @brief Remove an address from the interface.
*
- * @param[in] pid The PID to the interface.
+ * @param[in] pid The PID to the interface. If @p pid is KERNEL_PID_UNDEF
+ * 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);
@@ -254,12 +338,37 @@ ng_ipv6_addr_t *ng_ipv6_netif_match_prefix(kernel_pid_t pid,
*/
ng_ipv6_addr_t *ng_ipv6_netif_find_best_src_addr(kernel_pid_t pid, const ng_ipv6_addr_t *dest);
+/**
+ * @brief Get interface specific meta-information on an address
+ *
+ * @details This only works with addresses you retrieved via the following
+ * functions:
+ *
+ * * ng_ipv6_netif_add_addr()
+ * * ng_ipv6_find_addr()
+ * * ng_ipv6_find_addr_local()
+ * * ng_ipv6_find_prefix_match()
+ * * ng_ipv6_find_prefix_match_local()
+ * * ng_ipv6_find_best_src_address()
+ *
+ * The behaviour for other addresses is undefined.
+ *
+ * @param[in] addr The address you want to get the meta-information for.
+ *
+ * @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)
+{
+ return container_of(addr, ng_ipv6_netif_addr_t, addr);
+}
+
/**
* @brief Checks if an address is non-unicast.
*
* @details This only works with addresses you retrieved via the following
* functions:
*
+ * * ng_ipv6_netif_add_addr()
* * ng_ipv6_find_addr()
* * ng_ipv6_find_addr_local()
* * ng_ipv6_find_prefix_match()
diff --git a/sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c b/sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c
index 65058940ce..cebff338ae 100644
--- a/sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c
+++ b/sys/net/network_layer/ng_ipv6/netif/ng_ipv6_netif.c
@@ -20,7 +20,6 @@
#include "kernel_types.h"
#include "mutex.h"
-#include "net/ng_ipv6.h"
#include "net/ng_ipv6/addr.h"
#include "net/ng_netif.h"
@@ -35,31 +34,28 @@ static ng_ipv6_netif_t ipv6_ifs[NG_NETIF_NUMOF];
static char addr_str[NG_IPV6_ADDR_MAX_STR_LEN];
#endif
-static int _add_addr_to_entry(ng_ipv6_netif_t *entry, const ng_ipv6_addr_t *addr,
- uint8_t prefix_len, bool anycast)
+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)
{
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
if (ng_ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
- return 0;
+ return &(entry->addrs[i].addr);
}
if (ng_ipv6_addr_is_unspecified(&(entry->addrs[i].addr))) {
memcpy(&(entry->addrs[i].addr), addr, sizeof(ng_ipv6_addr_t));
- DEBUG("Added %s/%" PRIu8 " to interface %" PRIkernel_pid "\n",
+ DEBUG("ipv6 netif: Added %s/%" PRIu8 " to interface %" PRIkernel_pid "\n",
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
prefix_len, entry->pid);
- if (anycast || ng_ipv6_addr_is_multicast(addr)) {
- if (ng_ipv6_addr_is_multicast(addr)) {
- entry->addrs[i].prefix_len = NG_IPV6_ADDR_BIT_LEN;
- }
+ entry->addrs[i].prefix_len = prefix_len;
+ entry->addrs[i].flags = flags;
- entry->addrs[i].flags = NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST;
-
- return 0;
+ if (ng_ipv6_addr_is_multicast(addr)) {
+ entry->addrs[i].flags |= NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST;
}
else {
- entry->addrs[i].prefix_len = prefix_len;
+ ng_ipv6_addr_t sol_node;
if (!ng_ipv6_addr_is_link_local(addr)) {
/* add also corresponding link-local address */
@@ -68,22 +64,27 @@ static int _add_addr_to_entry(ng_ipv6_netif_t *entry, const ng_ipv6_addr_t *addr
ll_addr.u64[1] = addr->u64[1];
ng_ipv6_addr_set_link_local_prefix(&ll_addr);
- entry->addrs[i].flags = NG_IPV6_NETIF_ADDR_FLAGS_UNICAST;
-
- return _add_addr_to_entry(entry, &ll_addr, 64, false);
+ _add_addr_to_entry(entry, &ll_addr, 64,
+ flags | NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK);
+ }
+ else {
+ entry->addrs[i].flags |= NG_IPV6_NETIF_ADDR_FLAGS_NDP_ON_LINK;
}
- return 0;
+ ng_ipv6_addr_set_solicited_nodes(&sol_node, addr);
+ _add_addr_to_entry(entry, &sol_node, NG_IPV6_ADDR_BIT_LEN, 0);
}
+
+ return &entry->addrs[i].addr;
}
}
- return -ENOMEM;
+ return NULL;
}
static void _reset_addr_from_entry(ng_ipv6_netif_t *entry)
{
- DEBUG("Reset IPv6 addresses on interface %" PRIkernel_pid "\n", entry->pid);
+ DEBUG("ipv6 netif: Reset IPv6 addresses on interface %" PRIkernel_pid "\n", entry->pid);
memset(entry->addrs, 0, sizeof(entry->addrs));
}
@@ -108,23 +109,25 @@ void ng_ipv6_netif_add(kernel_pid_t pid)
ng_ipv6_addr_t addr = NG_IPV6_ADDR_ALL_NODES_LINK_LOCAL;
mutex_lock(&ipv6_ifs[i].mutex);
- DEBUG("Add IPv6 interface %" PRIkernel_pid " (i = %d)\n", pid, i);
+ DEBUG("ipv6 netif: Add IPv6 interface %" PRIkernel_pid " (i = %d)\n", pid, i);
ipv6_ifs[i].pid = pid;
- DEBUG(" * pid = %" PRIkernel_pid " ", ipv6_ifs[i].pid);
ipv6_ifs[i].mtu = NG_IPV6_NETIF_DEFAULT_MTU;
- DEBUG("mtu = %d ", ipv6_ifs[i].mtu);
ipv6_ifs[i].cur_hl = NG_IPV6_NETIF_DEFAULT_HL;
- DEBUG("cur_hl = %d ", ipv6_ifs[i].cur_hl);
+ ipv6_ifs[i].flags = 0;
_add_addr_to_entry(&ipv6_ifs[i], &addr, NG_IPV6_ADDR_BIT_LEN, 0);
mutex_unlock(&ipv6_ifs[i].mutex);
+ DEBUG(" * pid = %" PRIkernel_pid " ", ipv6_ifs[i].pid);
+ DEBUG("cur_hl = %d ", ipv6_ifs[i].cur_hl);
+ DEBUG("mtu = %d ", ipv6_ifs[i].mtu);
+ DEBUG("flags = %04" PRIx16 "\n", ipv6_ifs[i].flags);
return;
}
}
- DEBUG("Could not add %" PRIkernel_pid " to IPv6: No space left.\n", pid);
+ DEBUG("ipv6 netif: Could not add %" PRIkernel_pid " to IPv6: No space left.\n", pid);
}
void ng_ipv6_netif_remove(kernel_pid_t pid)
@@ -138,8 +141,9 @@ void ng_ipv6_netif_remove(kernel_pid_t pid)
mutex_lock(&entry->mutex);
_reset_addr_from_entry(entry);
- DEBUG("Remove IPv6 interface %" PRIkernel_pid "\n", pid);
+ DEBUG("ipv6 netif: Remove IPv6 interface %" PRIkernel_pid "\n", pid);
entry->pid = KERNEL_PID_UNDEF;
+ entry->flags = 0;
mutex_unlock(&entry->mutex);
}
@@ -148,7 +152,7 @@ ng_ipv6_netif_t *ng_ipv6_netif_get(kernel_pid_t pid)
{
for (int i = 0; i < NG_NETIF_NUMOF; i++) {
if (ipv6_ifs[i].pid == pid) {
- DEBUG("Get IPv6 interface %" PRIkernel_pid " (%p, i = %d)\n", pid,
+ DEBUG("ipv6 netif: Get IPv6 interface %" PRIkernel_pid " (%p, i = %d)\n", pid,
(void *)(&(ipv6_ifs[i])), i);
return &(ipv6_ifs[i]);
}
@@ -157,44 +161,34 @@ ng_ipv6_netif_t *ng_ipv6_netif_get(kernel_pid_t pid)
return NULL;
}
-int ng_ipv6_netif_add_addr(kernel_pid_t pid, const ng_ipv6_addr_t *addr,
- uint8_t prefix_len, bool anycast)
+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)
{
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
- int res;
+ ng_ipv6_addr_t *res;
- if (entry == NULL) {
- return -ENOENT;
- }
-
- if ((addr == NULL) || (ng_ipv6_addr_is_unspecified(addr)) ||
+ if ((entry == NULL) || (addr == NULL) || (ng_ipv6_addr_is_unspecified(addr)) ||
((prefix_len - 1) > 127)) { /* prefix_len < 1 || prefix_len > 128 */
- return -EINVAL;
+ return NULL;
}
mutex_lock(&entry->mutex);
- res = _add_addr_to_entry(entry, addr, prefix_len, anycast);
+ res = _add_addr_to_entry(entry, addr, prefix_len, flags);
mutex_unlock(&entry->mutex);
return res;
}
-void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ng_ipv6_addr_t *addr)
+static void _remove_addr_from_entry(ng_ipv6_netif_t *entry, ng_ipv6_addr_t *addr)
{
- ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
-
- if (entry == NULL) {
- return;
- }
-
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)) {
- DEBUG("Remove %s to interface %" PRIkernel_pid "\n",
- ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), pid);
+ 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));
entry->addrs[i].flags = 0;
@@ -206,6 +200,24 @@ void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ng_ipv6_addr_t *addr)
mutex_unlock(&entry->mutex);
}
+void ng_ipv6_netif_remove_addr(kernel_pid_t pid, ng_ipv6_addr_t *addr)
+{
+ if (pid == KERNEL_PID_UNDEF) {
+ for (int i = 0; i < NG_NETIF_NUMOF; i++) {
+ if (ipv6_ifs[i].pid == KERNEL_PID_UNDEF) {
+ continue;
+ }
+
+ _remove_addr_from_entry(ipv6_ifs + i, addr);
+ }
+ }
+ else {
+ ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
+
+ _remove_addr_from_entry(entry, addr);
+ }
+}
+
void ng_ipv6_netif_reset_addr(kernel_pid_t pid)
{
ng_ipv6_netif_t *entry = ng_ipv6_netif_get(pid);
@@ -228,7 +240,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out, const ng_ipv6_addr
*out = ng_ipv6_netif_find_addr(ipv6_ifs[i].pid, addr);
if (*out != NULL) {
- DEBUG("Found %s on interface %" PRIkernel_pid "\n",
+ DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid "\n",
ng_ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
ipv6_ifs[i].pid);
return ipv6_ifs[i].pid;
@@ -236,7 +248,7 @@ kernel_pid_t ng_ipv6_netif_find_by_addr(ng_ipv6_addr_t **out, const ng_ipv6_addr
}
else {
if (ng_ipv6_netif_find_addr(ipv6_ifs[i].pid, addr) != NULL) {
- DEBUG("Found %s on interface %" PRIkernel_pid "\n",
+ DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid "\n",
ng_ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
ipv6_ifs[i].pid);
return ipv6_ifs[i].pid;
@@ -264,7 +276,7 @@ ng_ipv6_addr_t *ng_ipv6_netif_find_addr(kernel_pid_t pid, const ng_ipv6_addr_t *
for (int i = 0; i < NG_IPV6_NETIF_ADDR_NUMOF; i++) {
if (ng_ipv6_addr_equal(&(entry->addrs[i].addr), addr)) {
mutex_unlock(&entry->mutex);
- DEBUG("Found %s on interface %" PRIkernel_pid "\n",
+ DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid "\n",
ng_ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
pid);
return &(entry->addrs[i].addr);
@@ -307,9 +319,8 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
}
#if ENABLE_DEBUG
-
if (*res != NULL) {
- DEBUG("Found %s on interface %" PRIkernel_pid " matching ",
+ DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid " matching ",
ng_ipv6_addr_to_str(addr_str, *res, sizeof(addr_str)),
iface->pid);
DEBUG("%s by %" PRIu8 " bits (used as source address = %s)\n",
@@ -318,14 +329,14 @@ static uint8_t _find_by_prefix_unsafe(ng_ipv6_addr_t **res, ng_ipv6_netif_t *ifa
(only_unicast) ? "true" : "false");
}
else {
- DEBUG("Did not found any address on interface %" PRIkernel_pid
+ 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)),
(only_unicast) ? "true" : "false");
}
-
#endif
+
return best_match;
}
@@ -355,9 +366,8 @@ 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("Found %s on interface %" PRIkernel_pid " globally matching ",
+ DEBUG("ipv6 netif: Found %s on interface %" PRIkernel_pid " globally matching ",
ng_ipv6_addr_to_str(addr_str, *out, sizeof(addr_str)),
res);
DEBUG("%s by %" PRIu8 " bits\n",
@@ -365,10 +375,9 @@ kernel_pid_t ng_ipv6_netif_find_by_prefix(ng_ipv6_addr_t **out, const ng_ipv6_ad
best_match);
}
else {
- DEBUG("Did not found any address globally matching %s\n",
+ DEBUG("ipv6 netif: Did not found any address globally matching %s\n",
ng_ipv6_addr_to_str(addr_str, prefix, sizeof(addr_str)));
}
-
#endif
return res;
diff --git a/sys/shell/commands/sc_netif.c b/sys/shell/commands/sc_netif.c
index 3c7d4d18ca..32657fc4c5 100644
--- a/sys/shell/commands/sc_netif.c
+++ b/sys/shell/commands/sc_netif.c
@@ -600,7 +600,10 @@ static int _netif_add(char *cmd_name, kernel_pid_t dev, int argc, char **argv)
return 1;
}
- if (ng_ipv6_netif_add_addr(dev, &addr, prefix_len, (type == _ANYCAST)) < 0) {
+ if (ng_ipv6_netif_add_addr(dev, &addr, prefix_len,
+ (type == _ANYCAST) ?
+ NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST :
+ NG_IPV6_NETIF_ADDR_FLAGS_UNICAST) == NULL) {
printf("error: unable to add IPv6 address\n");
return 1;
}
diff --git a/tests/unittests/tests-ipv6_netif/tests-ipv6_netif.c b/tests/unittests/tests-ipv6_netif/tests-ipv6_netif.c
index 5c9cb3aa47..3654f0deba 100644
--- a/tests/unittests/tests-ipv6_netif/tests-ipv6_netif.c
+++ b/tests/unittests/tests-ipv6_netif/tests-ipv6_netif.c
@@ -121,22 +121,19 @@ static void test_ipv6_netif_add_addr__no_iface1(void)
{
ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
- TEST_ASSERT_EQUAL_INT(-ENOENT, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF,
- &addr, DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0));
}
static void test_ipv6_netif_add_addr__no_iface2(void)
{
- TEST_ASSERT_EQUAL_INT(-ENOENT, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF,
- NULL, DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, NULL, DEFAULT_TEST_PREFIX_LEN, 0));
}
static void test_ipv6_netif_add_addr__addr_NULL(void)
{
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(-EINVAL, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF,
- NULL, DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, NULL, DEFAULT_TEST_PREFIX_LEN, 0));
}
static void test_ipv6_netif_add_addr__addr_unspecified(void)
@@ -145,26 +142,22 @@ static void test_ipv6_netif_add_addr__addr_unspecified(void)
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(-EINVAL, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF,
- &addr, DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0));
}
-static void test_ipv6_netif_add_addr__ENOMEM(void)
+static void test_ipv6_netif_add_addr__full(void)
{
- ng_ipv6_addr_t addr = DEFAULT_TEST_IPV6_ADDR;
- int res = 0, i;
+ ng_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);
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- for (i = 0; res != -ENOMEM; i++, addr.u8[15]++) {
- res = ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr,
- DEFAULT_TEST_PREFIX_LEN, false);
+ for (i = 0; res != NULL; i++, addr.u8[15]++) {
+ res = ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0);
}
-
- TEST_ASSERT_EQUAL_INT(NG_IPV6_NETIF_ADDR_NUMOF, i);
}
static void test_ipv6_netif_add_addr__success(void)
@@ -173,8 +166,7 @@ static void test_ipv6_netif_add_addr__success(void)
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr,
- DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0));
}
static void test_ipv6_netif_remove_addr__not_allocated(void)
@@ -378,10 +370,10 @@ static void test_ipv6_netif_find_best_src_addr__no_unicast(void)
TEST_ASSERT_EQUAL_INT(126, ng_ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr,
- DEFAULT_TEST_PREFIX_LEN, false));
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr1,
- DEFAULT_TEST_PREFIX_LEN, true));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr, DEFAULT_TEST_PREFIX_LEN,
+ 0));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr1, DEFAULT_TEST_PREFIX_LEN,
+ NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST));
TEST_ASSERT_NULL(ng_ipv6_netif_find_best_src_addr(DEFAULT_TEST_NETIF, &ll_addr2));
}
@@ -401,10 +393,10 @@ static void test_ipv6_netif_find_best_src_addr__success(void)
TEST_ASSERT_EQUAL_INT(126, ng_ipv6_addr_match_prefix(&ll_addr2, &ll_addr1));
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr,
- DEFAULT_TEST_PREFIX_LEN, false));
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr1,
- DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &mc_addr, DEFAULT_TEST_PREFIX_LEN,
+ 0));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &ll_addr1, DEFAULT_TEST_PREFIX_LEN,
+ 0));
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_best_src_addr(DEFAULT_TEST_NETIF, &ll_addr2)));
TEST_ASSERT(out != &ll_addr1);
@@ -431,8 +423,8 @@ static void test_ipv6_netif_addr_is_non_unicast__anycast(void)
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr,
- DEFAULT_TEST_PREFIX_LEN, true));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN,
+ NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST));
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr)));
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_netif_addr_is_non_unicast(out));
@@ -445,8 +437,7 @@ static void test_ipv6_netif_addr_is_non_unicast__multicast1(void)
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr,
- DEFAULT_TEST_PREFIX_LEN, false));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN, 0));
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr)));
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_netif_addr_is_non_unicast(out));
@@ -459,8 +450,8 @@ static void test_ipv6_netif_addr_is_non_unicast__multicast2(void)
test_ipv6_netif_add__success(); /* adds DEFAULT_TEST_NETIF as interface */
- TEST_ASSERT_EQUAL_INT(0, ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr,
- DEFAULT_TEST_PREFIX_LEN, true));
+ TEST_ASSERT_NOT_NULL(ng_ipv6_netif_add_addr(DEFAULT_TEST_NETIF, &addr, DEFAULT_TEST_PREFIX_LEN,
+ NG_IPV6_NETIF_ADDR_FLAGS_NON_UNICAST));
TEST_ASSERT_NOT_NULL((out = ng_ipv6_netif_find_addr(DEFAULT_TEST_NETIF, &addr)));
TEST_ASSERT_EQUAL_INT(true, ng_ipv6_netif_addr_is_non_unicast(out));
@@ -478,7 +469,7 @@ Test *tests_ipv6_netif_tests(void)
new_TestFixture(test_ipv6_netif_add_addr__no_iface2),
new_TestFixture(test_ipv6_netif_add_addr__addr_NULL),
new_TestFixture(test_ipv6_netif_add_addr__addr_unspecified),
- new_TestFixture(test_ipv6_netif_add_addr__ENOMEM),
+ new_TestFixture(test_ipv6_netif_add_addr__full),
new_TestFixture(test_ipv6_netif_add_addr__success),
new_TestFixture(test_ipv6_netif_remove_addr__not_allocated),
new_TestFixture(test_ipv6_netif_remove_addr__success),