mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-25 06:23:53 +01:00
Merge pull request #8073 from miri64/gnrc_ipv6_nib/feat/route-timeout
gnrc_ipv6_nib: add timeouts to routes
This commit is contained in:
commit
4a0d57c6fa
@ -192,6 +192,16 @@ extern "C" {
|
||||
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_6LN != 0
|
||||
*/
|
||||
#define GNRC_IPV6_NIB_REREG_ADDRESS (0x4fcfU)
|
||||
|
||||
/**
|
||||
* @brief Route timeout event.
|
||||
*
|
||||
* This message type is for the event of a route timeout. The expected message
|
||||
* context is a valid off-link entry representing the route.
|
||||
*
|
||||
* @note Only handled with @ref GNRC_IPV6_NIB_CONF_ROUTER != 0
|
||||
*/
|
||||
#define GNRC_IPV6_NIB_ROUTE_TIMEOUT (0x4fd0U)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
@ -69,13 +69,16 @@ int gnrc_ipv6_nib_ft_get(const ipv6_addr_t *dst, gnrc_pktsnip_t *pkt,
|
||||
* @param[in] next_hop The next hop to @p dst/@p dst_len. May be NULL, if
|
||||
* @p dst/@p dst_len is no the default route.
|
||||
* @param[in] iface The interface to @p next_hop. May not be 0.
|
||||
* @param[in] lifetime Lifetime of the route in seconds. 0 for infinite
|
||||
* lifetime.
|
||||
*
|
||||
* @return 0, on success.
|
||||
* @return -EINVAL, if a parameter was of invalid value.
|
||||
* @return -ENOMEM, if there was no space left in forwarding table.
|
||||
*/
|
||||
int gnrc_ipv6_nib_ft_add(const ipv6_addr_t *dst, unsigned dst_len,
|
||||
const ipv6_addr_t *next_hop, unsigned iface);
|
||||
const ipv6_addr_t *next_hop, unsigned iface,
|
||||
uint16_t lifetime);
|
||||
|
||||
/**
|
||||
* @brief Deletes a route from forwarding table.
|
||||
|
||||
@ -35,7 +35,7 @@ static void set_interface_roles(void)
|
||||
ipv6_addr_from_str(&addr, "fe80::2");
|
||||
gnrc_netapi_set(dev, NETOPT_IPV6_ADDR, 64 << 8, &addr, sizeof(addr));
|
||||
ipv6_addr_from_str(&addr, "fe80::1");
|
||||
gnrc_ipv6_nib_ft_add(&defroute, IPV6_ADDR_BIT_LEN, &addr, dev);
|
||||
gnrc_ipv6_nib_ft_add(&defroute, IPV6_ADDR_BIT_LEN, &addr, dev, 0);
|
||||
}
|
||||
else if ((!gnrc_wireless_interface) && (is_wired != 1)) {
|
||||
gnrc_wireless_interface = dev;
|
||||
|
||||
@ -298,6 +298,7 @@ static void *_event_loop(void *args)
|
||||
case GNRC_IPV6_NIB_RTR_TIMEOUT:
|
||||
case GNRC_IPV6_NIB_RECALC_REACH_TIME:
|
||||
case GNRC_IPV6_NIB_REREG_ADDRESS:
|
||||
case GNRC_IPV6_NIB_ROUTE_TIMEOUT:
|
||||
DEBUG("ipv6: NIB timer event received\n");
|
||||
gnrc_ipv6_nib_handle_timer_event(msg.content.ptr, msg.type);
|
||||
break;
|
||||
|
||||
@ -196,14 +196,20 @@ typedef struct {
|
||||
typedef struct {
|
||||
_nib_onl_entry_t *next_hop; /**< next hop to destination */
|
||||
ipv6_addr_t pfx; /**< prefix to the destination */
|
||||
unsigned pfx_len; /**< prefix-length in bits of
|
||||
* _nib_onl_entry_t::pfx */
|
||||
/**
|
||||
* @brief Event for @ref GNRC_IPV6_NIB_PFX_TIMEOUT
|
||||
*/
|
||||
evtimer_msg_event_t pfx_timeout;
|
||||
#ifdef GNRC_IPV6_NIB_CONF_ROUTER
|
||||
/**
|
||||
* @brief Event for @ref GNRC_IPV6_NIB_ROUTE_TIMEOUT
|
||||
*/
|
||||
evtimer_msg_event_t route_timeout;
|
||||
#endif
|
||||
uint8_t mode; /**< [mode](@ref net_gnrc_ipv6_nib_mode) of the
|
||||
* off-link entry */
|
||||
uint8_t pfx_len; /**< prefix-length in bits of
|
||||
* _nib_onl_entry_t::pfx */
|
||||
uint16_t flags; /**< [flags](@ref net_gnrc_ipv6_nib_offl_flags */
|
||||
uint32_t valid_until; /**< timestamp (in ms) until which the prefix
|
||||
valid (UINT32_MAX means forever) */
|
||||
|
||||
@ -324,6 +324,9 @@ void gnrc_ipv6_nib_handle_timer_event(void *ctx, uint16_t type)
|
||||
case GNRC_IPV6_NIB_SND_MC_RA:
|
||||
_handle_snd_mc_ra(ctx);
|
||||
break;
|
||||
case GNRC_IPV6_NIB_ROUTE_TIMEOUT:
|
||||
_nib_ft_remove(ctx);
|
||||
break;
|
||||
#endif /* GNRC_IPV6_NIB_CONF_ROUTER */
|
||||
#if GNRC_IPV6_NIB_CONF_6LR
|
||||
case GNRC_IPV6_NIB_ADDR_REG_TIMEOUT:
|
||||
|
||||
@ -33,9 +33,9 @@ int gnrc_ipv6_nib_ft_get(const ipv6_addr_t *dst, gnrc_pktsnip_t *pkt,
|
||||
}
|
||||
|
||||
int gnrc_ipv6_nib_ft_add(const ipv6_addr_t *dst, unsigned dst_len,
|
||||
const ipv6_addr_t *next_hop, unsigned iface)
|
||||
const ipv6_addr_t *next_hop, unsigned iface,
|
||||
uint16_t ltime)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
int res = 0;
|
||||
bool is_default_route = ((dst == NULL) || (dst_len == 0) ||
|
||||
ipv6_addr_is_unspecified(dst));
|
||||
@ -45,12 +45,30 @@ int gnrc_ipv6_nib_ft_add(const ipv6_addr_t *dst, unsigned dst_len,
|
||||
}
|
||||
mutex_lock(&_nib_mutex);
|
||||
if (is_default_route) {
|
||||
_nib_dr_entry_t *ptr;
|
||||
|
||||
ptr = _nib_drl_add(next_hop, iface);
|
||||
if (ptr == NULL) {
|
||||
res = -ENOMEM;
|
||||
}
|
||||
else if (ltime > 0) {
|
||||
_evtimer_add(ptr, GNRC_IPV6_NIB_RTR_TIMEOUT,
|
||||
&ptr->rtr_timeout, ltime * MS_PER_SEC);
|
||||
}
|
||||
}
|
||||
#if GNRC_IPV6_NIB_CONF_ROUTER
|
||||
else {
|
||||
_nib_offl_entry_t *ptr;
|
||||
|
||||
dst_len = (dst_len > 128) ? 128 : dst_len;
|
||||
ptr = _nib_ft_add(next_hop, iface, dst, dst_len);
|
||||
if (ptr == NULL) {
|
||||
res = -ENOMEM;
|
||||
}
|
||||
else if (ltime > 0) {
|
||||
_evtimer_add(ptr, GNRC_IPV6_NIB_ROUTE_TIMEOUT,
|
||||
&ptr->route_timeout, ltime * MS_PER_SEC);
|
||||
}
|
||||
}
|
||||
#else /* GNRC_IPV6_NIB_CONF_ROUTER */
|
||||
else {
|
||||
@ -58,9 +76,6 @@ int gnrc_ipv6_nib_ft_add(const ipv6_addr_t *dst, unsigned dst_len,
|
||||
}
|
||||
#endif
|
||||
mutex_unlock(&_nib_mutex);
|
||||
if (ptr == NULL) {
|
||||
res = -ENOMEM;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ static void _usage_nib_prefix(char **argv)
|
||||
static void _usage_nib_route(char **argv)
|
||||
{
|
||||
printf("usage: %s %s [show|add|del|help]\n", argv[0], argv[1]);
|
||||
printf(" %s %s add <iface> <prefix>[/<prefix_len>] <next_hop>\n",
|
||||
printf(" %s %s add <iface> <prefix>[/<prefix_len>] <next_hop> [<ltime in sec>]\n",
|
||||
argv[0], argv[1]);
|
||||
printf(" %s %s del <iface> <prefix>[/<prefix_len>]\n", argv[0], argv[1]);
|
||||
printf(" %s %s show <iface>\n", argv[0], argv[1]);
|
||||
@ -202,6 +202,7 @@ static int _nib_route(int argc, char **argv)
|
||||
ipv6_addr_t pfx = IPV6_ADDR_UNSPECIFIED, next_hop;
|
||||
unsigned iface = atoi(argv[3]);
|
||||
unsigned pfx_len = ipv6_addr_split_prefix(argv[4]);
|
||||
uint16_t ltime = 0;
|
||||
|
||||
if (ipv6_addr_from_str(&pfx, argv[4]) == NULL) {
|
||||
/* check if string equals "default"
|
||||
@ -215,7 +216,10 @@ static int _nib_route(int argc, char **argv)
|
||||
_usage_nib_route(argv);
|
||||
return 1;
|
||||
}
|
||||
gnrc_ipv6_nib_ft_add(&pfx, pfx_len, &next_hop, iface);
|
||||
if (argc > 6) {
|
||||
ltime = (uint16_t)atoi(argv[6]);
|
||||
}
|
||||
gnrc_ipv6_nib_ft_add(&pfx, pfx_len, &next_hop, iface, ltime);
|
||||
}
|
||||
else if ((argc > 4) && (strcmp(argv[2], "del") == 0)) {
|
||||
ipv6_addr_t pfx;
|
||||
|
||||
@ -113,7 +113,7 @@ static void test_get_next_hop_l2addr__EHOSTUNREACH(const ipv6_addr_t *dst,
|
||||
}
|
||||
else {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0, &_rem_ll,
|
||||
_mock_netif->pid));
|
||||
_mock_netif->pid, 0));
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-EHOSTUNREACH,
|
||||
gnrc_ipv6_nib_get_next_hop_l2addr(dst, netif,
|
||||
|
||||
@ -176,7 +176,7 @@ static void test_get_next_hop_l2addr__global_with_default_route(void)
|
||||
|
||||
/* add _rem_ll as default router */
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0, &_rem_ll,
|
||||
_mock_netif->pid));
|
||||
_mock_netif->pid, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_get_next_hop_l2addr(&_rem_gb,
|
||||
NULL, NULL,
|
||||
&nce));
|
||||
|
||||
@ -70,7 +70,7 @@ static void test_nib_ft_get__ENETUNREACH_no_def_route(void)
|
||||
ipv6_addr_t dst = { .u64 = { { .u8 = GLOBAL_PREFIX } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
dst.u16[0].u16--;
|
||||
TEST_ASSERT_EQUAL_INT(-ENETUNREACH, gnrc_ipv6_nib_ft_get(&dst, NULL, &fte));
|
||||
}
|
||||
@ -88,7 +88,7 @@ static void test_nib_ft_get__success1(void)
|
||||
static const ipv6_addr_t next_hop = { .u64 = { { .u8 = LINK_LOCAL_PREFIX },
|
||||
{ .u64 = TEST_UINT64 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0, &next_hop, IFACE));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0, &next_hop, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_get(&dst, NULL, &fte));
|
||||
TEST_ASSERT(ipv6_addr_is_unspecified(&fte.dst));
|
||||
TEST_ASSERT(ipv6_addr_equal(&next_hop, &fte.next_hop));
|
||||
@ -111,7 +111,7 @@ static void test_nib_ft_get__success2(void)
|
||||
{ .u64 = TEST_UINT64 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_get(&dst, NULL, &fte));
|
||||
TEST_ASSERT(ipv6_addr_match_prefix(&dst, &fte.dst) >= GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT(ipv6_addr_equal(&next_hop, &fte.next_hop));
|
||||
@ -139,9 +139,9 @@ static void test_nib_ft_get__success3(void)
|
||||
|
||||
bf_toggle(dst2.u8, GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst1, GLOBAL_PREFIX_LEN,
|
||||
&next_hop1, IFACE));
|
||||
&next_hop1, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst2, GLOBAL_PREFIX_LEN,
|
||||
&next_hop2, IFACE));
|
||||
&next_hop2, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_get(&dst1, NULL, &fte));
|
||||
TEST_ASSERT(ipv6_addr_match_prefix(&dst1, &fte.dst) >= GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT(ipv6_addr_equal(&next_hop1, &fte.next_hop));
|
||||
@ -167,9 +167,9 @@ static void test_nib_ft_get__success4(void)
|
||||
{ .u64 = TEST_UINT64 + 1 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop1, IFACE));
|
||||
&next_hop1, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN - 1,
|
||||
&next_hop2, IFACE));
|
||||
&next_hop2, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_get(&dst, NULL, &fte));
|
||||
TEST_ASSERT(ipv6_addr_match_prefix(&dst, &fte.dst) >= GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT(ipv6_addr_equal(&next_hop1, &fte.next_hop));
|
||||
@ -190,11 +190,11 @@ static void test_nib_ft_add__EINVAL_def_route_next_hop_NULL(void)
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(&ipv6_addr_unspecified,
|
||||
GLOBAL_PREFIX_LEN,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(NULL, GLOBAL_PREFIX_LEN,
|
||||
NULL, IFACE));
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(&dst, 0, NULL, IFACE));
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(NULL, 0, NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(&dst, 0, NULL, IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(NULL, 0, NULL, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -209,7 +209,7 @@ static void test_nib_ft_add__EINVAL_iface0(void)
|
||||
{ .u64 = TEST_UINT64 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(-EINVAL, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, 0));
|
||||
&next_hop, 0, 0));
|
||||
}
|
||||
|
||||
#if GNRC_IPV6_NIB_NUMOF < GNRC_IPV6_NIB_OFFL_NUMOF
|
||||
@ -230,11 +230,11 @@ static void test_nib_ft_add__ENOMEM_diff_def_router(void)
|
||||
|
||||
for (unsigned i = 0; i < GNRC_IPV6_NIB_DEFAULT_ROUTER_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0, &next_hop,
|
||||
IFACE));
|
||||
IFACE, 0));
|
||||
next_hop.u64[1].u64++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(NULL, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -248,11 +248,11 @@ static void test_nib_ft_add__ENOMEM_diff_dst(void)
|
||||
|
||||
for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
dst.u16[0].u16--;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -267,11 +267,11 @@ static void test_nib_ft_add__ENOMEM_diff_dst_len(void)
|
||||
|
||||
for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
dst_len--;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -287,12 +287,12 @@ static void test_nib_ft_add__ENOMEM_diff_dst_dst_len(void)
|
||||
|
||||
for (unsigned i = 0; i < GNRC_IPV6_NIB_OFFL_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
dst.u16[0].u16--;
|
||||
dst_len--;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, IFACE));
|
||||
NULL, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -308,11 +308,11 @@ static void test_nib_ft_add__ENOMEM_diff_next_hop(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
next_hop.u64[1].u64++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -328,12 +328,12 @@ static void test_nib_ft_add__ENOMEM_diff_dst_next_hop(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
dst.u16[0].u16--;
|
||||
next_hop.u64[1].u64++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -350,13 +350,13 @@ static void test_nib_ft_add__ENOMEM_diff_dst_dst_len_next_hop(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, &next_hop,
|
||||
IFACE));
|
||||
IFACE, 0));
|
||||
dst.u16[0].u16--;
|
||||
dst_len--;
|
||||
next_hop.u64[1].u64++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -372,12 +372,12 @@ static void test_nib_ft_add__ENOMEM_diff_dst_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
dst.u16[0].u16--;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -394,12 +394,12 @@ static void test_nib_ft_add__ENOMEM_diff_dst_len_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
dst_len--;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -416,13 +416,13 @@ static void test_nib_ft_add__ENOMEM_diff_dst_dst_len_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
dst.u16[0].u16--;
|
||||
dst_len--;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
NULL, iface));
|
||||
NULL, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -439,12 +439,12 @@ static void test_nib_ft_add__ENOMEM_diff_next_hop_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
next_hop.u64[1].u64++;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -461,13 +461,13 @@ static void test_nib_ft_add__ENOMEM_diff_dst_next_hop_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
dst.u16[0].u16--;
|
||||
next_hop.u64[1].u64++;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -486,14 +486,14 @@ static void test_nib_ft_add__ENOMEM_diff_dst_dst_len_next_hop_iface(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, &next_hop,
|
||||
iface));
|
||||
iface, 0));
|
||||
dst.u16[0].u16--;
|
||||
dst_len--;
|
||||
next_hop.u64[1].u64++;
|
||||
iface++;
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(-ENOMEM, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -515,10 +515,10 @@ static void test_nib_ft_add__success_duplicate(void)
|
||||
next_hop.u64[1].u64++;
|
||||
iface++;
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, &next_hop,
|
||||
iface));
|
||||
iface, 0));
|
||||
}
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len,
|
||||
&next_hop, iface));
|
||||
&next_hop, iface, 0));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -536,9 +536,9 @@ static void test_nib_ft_add__success_overwrite_unspecified(void)
|
||||
{ .u64 = TEST_UINT64 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN, NULL,
|
||||
IFACE));
|
||||
IFACE, 0));
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
TEST_ASSERT(gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte));
|
||||
TEST_ASSERT(ipv6_addr_equal(&fte.next_hop, &next_hop));
|
||||
TEST_ASSERT(!gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte));
|
||||
@ -558,7 +558,7 @@ static void test_nib_ft_add__success(void)
|
||||
{ .u64 = TEST_UINT64 } } };
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
TEST_ASSERT(gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte));
|
||||
TEST_ASSERT(ipv6_addr_match_prefix(&fte.dst, &dst) >= GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT_EQUAL_INT(GLOBAL_PREFIX_LEN, fte.dst_len);
|
||||
@ -586,7 +586,7 @@ static void test_nib_ft_del__unknown(void)
|
||||
|
||||
for (unsigned i = 0; i < MAX_NUMOF; i++) {
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, dst_len, &next_hop,
|
||||
iface));
|
||||
iface, 0));
|
||||
dst.u16[0].u16--;
|
||||
dst_len--;
|
||||
next_hop.u64[1].u64++;
|
||||
@ -612,7 +612,7 @@ static void test_nib_ft_del__success(void)
|
||||
gnrc_ipv6_nib_ft_t fte;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
gnrc_ipv6_nib_ft_del(&dst, GLOBAL_PREFIX_LEN);
|
||||
TEST_ASSERT(!gnrc_ipv6_nib_ft_iter(NULL ,0, &iter_state, &fte));
|
||||
}
|
||||
@ -632,13 +632,13 @@ static void test_nib_ft_iter__empty_def_route_at_beginning(void)
|
||||
int count = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
next_hop.u16[0].u16++;
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
next_hop.u16[0].u16++;
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(NULL, 0,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
gnrc_ipv6_nib_ft_del(NULL, 0);
|
||||
next_hop.u16[0].u16--;
|
||||
while (gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte)) {
|
||||
@ -669,13 +669,13 @@ static void test_nib_ft_iter__empty_pref_route_in_the_middle(void)
|
||||
int count = 0;
|
||||
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&route, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
route.u16[0].u16++;
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&route, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
route.u16[0].u16++;
|
||||
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&route, GLOBAL_PREFIX_LEN,
|
||||
&next_hop, IFACE));
|
||||
&next_hop, IFACE, 0));
|
||||
route.u16[0].u16--;
|
||||
gnrc_ipv6_nib_ft_del(&route, GLOBAL_PREFIX_LEN);
|
||||
route.u16[0].u16--;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user