From 8a200b3e484e4ab855df1d573fa8729240e81e75 Mon Sep 17 00:00:00 2001 From: xnumad <34810600+xnumad@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:26:17 +0100 Subject: [PATCH] tests/gnrc_ipv6_nib: rtr_ltime test --- tests/net/gnrc_ipv6_nib/main.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/net/gnrc_ipv6_nib/main.c b/tests/net/gnrc_ipv6_nib/main.c index 2694e6c0a0868..c262d0787cff7 100644 --- a/tests/net/gnrc_ipv6_nib/main.c +++ b/tests/net/gnrc_ipv6_nib/main.c @@ -1090,6 +1090,28 @@ static void test_handle_pkt__rtr_adv__success(uint8_t rtr_adv_flags, TEST_ASSERT_EQUAL_INT(exp_netif.cur_hl, _mock_netif->cur_hl); } + { + /* + * > The Router Lifetime applies only to + the router's usefulness as a default router; it + does not apply to information contained in other + message fields or options. + * - https://datatracker.ietf.org/doc/html/rfc4861#section-4.2 + * So (after default router list was tested), + * send a RA with Router Lifetime value of zero. + * to test that _handle_rtr_timeout follows this behavior. + * If it doesn't, the following tests for RA options will fail. + */ + icmpv6_len = _set_rtr_adv(&_rem_ll, NDP_HOP_LIMIT, 0U, + false, 0U, + NULL, sizeof(_rem_l2), + 0U, + NULL, _LOC_GB_PFX_LEN, + 0U); + ndp_rtr_adv_t *rtr_adv = (ndp_rtr_adv_t *)icmpv6; + rtr_adv->ltime = byteorder_htons(0); + gnrc_ipv6_nib_handle_pkt(_mock_netif, ipv6, icmpv6, icmpv6_len); + } state = NULL; if (sl2ao) { TEST_ASSERT_MESSAGE(gnrc_ipv6_nib_nc_iter(0, &state, &nce),