1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #13379 from cgundogan/pr/gnrc_rpl_p2p

gnrc_rpl_p2p: several compilation fixes
This commit is contained in:
Martine Lenders 2020-02-20 10:25:55 +01:00 committed by GitHub
commit c6331bfc77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 120 additions and 13 deletions

View File

@ -147,6 +147,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent);
*/
void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent);
/**
* @brief Removes the dodag state of @p dodag after
* GNRC_RPL_CLEANUP_TIME milliseconds
*
* @param[in] dodag Pointer to the DODAG
*/
void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag);
/**
* @brief Start a local repair.
*

View File

@ -246,6 +246,14 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
return true;
}
void gnrc_rpl_cleanup_start(gnrc_rpl_dodag_t *dodag)
{
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event);
((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = GNRC_RPL_CLEANUP_TIME;
dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP;
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid);
}
void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag)
{
DEBUG("RPL: [INFO] Local Repair started\n");
@ -260,10 +268,7 @@ void gnrc_rpl_local_repair(gnrc_rpl_dodag_t *dodag)
if (dodag->my_rank != GNRC_RPL_INFINITE_RANK) {
dodag->my_rank = GNRC_RPL_INFINITE_RANK;
trickle_reset_timer(&dodag->trickle);
evtimer_del((evtimer_t *)(&gnrc_rpl_evtimer), (evtimer_event_t *)&dodag->instance->cleanup_event);
((evtimer_event_t *)&(dodag->instance->cleanup_event))->offset = GNRC_RPL_CLEANUP_TIME;
dodag->instance->cleanup_event.msg.type = GNRC_RPL_MSG_TYPE_INSTANCE_CLEANUP;
evtimer_add_msg(&gnrc_rpl_evtimer, &dodag->instance->cleanup_event, gnrc_rpl_pid);
gnrc_rpl_cleanup_start(dodag);
}
}

View File

@ -56,7 +56,7 @@ void gnrc_rpl_p2p_update(void)
p2p_ext->lifetime_sec -= GNRC_RPL_LIFETIME_UPDATE_STEP;
if (p2p_ext->lifetime_sec <= 0) {
gnrc_rpl_dodag_remove_all_parents(p2p_ext->dodag);
p2p_ext->dodag->instance->cleanup = GNRC_RPL_CLEANUP_TIME;
gnrc_rpl_cleanup_start(p2p_ext->dodag);
continue;
}
p2p_ext->dro_delay -= GNRC_RPL_LIFETIME_UPDATE_STEP;
@ -110,9 +110,9 @@ gnrc_rpl_instance_t *gnrc_rpl_p2p_root_init(uint8_t instance_id, ipv6_addr_t *do
p2p_ext->maxrank = GNRC_RPL_P2P_MAX_RANK;
p2p_ext->dro_delay = -1;
trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL,
GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min),
dodag->dio_interval_doubl, dodag->dio_redun);
trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_MSG,
(1 << dodag->dio_min), dodag->dio_interval_doubl,
dodag->dio_redun);
return instance;
}
@ -163,7 +163,7 @@ void gnrc_rpl_p2p_rdo_parse(gnrc_rpl_p2p_opt_rdo_t *rdo, gnrc_rpl_p2p_ext_t *p2p
return;
}
p2p_ext->for_me = (gnrc_ipv6_netif_find_by_addr(NULL, &rdo->target) != KERNEL_PID_UNDEF);
p2p_ext->for_me = (gnrc_netif_get_by_ipv6_addr(&rdo->target) != NULL);
p2p_ext->reply = (rdo->compr_flags & (1 << GNRC_RPL_P2P_RDO_FLAGS_REPLY))
>> GNRC_RPL_P2P_RDO_FLAGS_REPLY;
@ -195,10 +195,19 @@ void gnrc_rpl_p2p_rdo_parse(gnrc_rpl_p2p_opt_rdo_t *rdo, gnrc_rpl_p2p_ext_t *p2p
if (!p2p_ext->for_me) {
ipv6_addr_t *me = NULL;
if(gnrc_ipv6_netif_find_by_prefix(&me, &p2p_ext->dodag->dodag_id) == KERNEL_PID_UNDEF) {
DEBUG("RPL: no address configured\n");
gnrc_netif_t *netif = gnrc_netif_get_by_pid(p2p_ext->dodag->iface);
if(netif == NULL) {
DEBUG("RPL: no interface configured\n");
return;
}
me = gnrc_netif_ipv6_addr_best_src(netif, &p2p_ext->dodag->dodag_id, false);
if(me == NULL) {
DEBUG("RPL: no source address found\n");
return;
}
addr = ((uint8_t *) &p2p_ext->addr_vec[i]) + p2p_ext->compr;
memcpy(addr, ((uint8_t *) me) + p2p_ext->compr, addr_len);
p2p_ext->addr_numof++;
@ -337,7 +346,6 @@ void gnrc_rpl_p2p_recv_DRO(gnrc_pktsnip_t *pkt, ipv6_addr_t *src)
addr_len = sizeof(ipv6_addr_t) - p2p_ext->compr;
ipv6_addr_t addr = p2p_ext->dodag->dodag_id;
ipv6_addr_t *me = NULL;
addr_vec = addr_snip->data;
rdo = rdo_snip->data;
@ -347,7 +355,9 @@ void gnrc_rpl_p2p_recv_DRO(gnrc_pktsnip_t *pkt, ipv6_addr_t *src)
memcpy(&addr.u8[p2p_ext->compr], &addr_vec[addr_len * rdo->lmn], addr_len);
}
if (gnrc_ipv6_netif_find_by_addr(&me, &addr) == dodag->iface) {
gnrc_netif_t *netif = gnrc_netif_get_by_ipv6_addr(&addr);
if (netif && (netif->pid == dodag->iface)) {
gnrc_ipv6_nib_ft_add(&p2p_ext->target, IPV6_ADDR_BIT_LEN, src, dodag->iface,
p2p_ext->dodag->default_lifetime *
p2p_ext->dodag->lifetime_unit);

View File

@ -0,0 +1,7 @@
include ../Makefile.tests_common
USEMODULE += gnrc_ipv6_router_default
USEMODULE += auto_init_gnrc_rpl
USEMODULE += gnrc_rpl_p2p
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,31 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-leonardo \
arduino-mega2560 \
arduino-nano \
arduino-uno \
atmega328p \
chronos \
i-nucleo-lrwan1 \
msb-430 \
msb-430h \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-f070rb \
nucleo-f072rb \
nucleo-f103rb \
nucleo-f302r8 \
nucleo-f303k8 \
nucleo-f334r8 \
nucleo-l031k6 \
nucleo-l053r8 \
stm32f030f4-demo \
stm32f0discovery \
stm32l0538-disco \
telosb \
waspmote-pro \
wsn430-v1_3b \
wsn430-v1_4 \
z1 \
#

28
tests/gnrc_rpl_p2p/main.c Normal file
View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 HAW
*
* 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.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Compile test for gnrc_rpl_p2p
*
* @author Cenk Gündoğan <mail+dev@gundogan.net>
*
* @}
*/
#include <stdio.h>
int main(void)
{
puts("[SUCCESS]");
return 0;
}

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# Copyright (C) 2020 HAW Hamburg
#
# 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.
import sys
from testrunner import run
def testfunc(child):
child.expect_exact(u"[SUCCESS]")
if __name__ == "__main__":
sys.exit(run(testfunc))