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

Merge pull request #2268 from cgundogan/rpl_cleanup_no_routing_table

rpl: remove routing table dependent code
This commit is contained in:
Ludwig Ortmann 2015-01-13 14:09:32 +01:00
commit 154a6b5d22
5 changed files with 39 additions and 14 deletions

View File

@ -66,8 +66,9 @@ ipv6_srh_t *srh_header;
msg_t srh_m_send, srh_m_recv;
#endif
#if RPL_MAX_ROUTING_ENTRIES != 0
rpl_routing_entry_t rpl_routing_table[RPL_MAX_ROUTING_ENTRIES];
#endif
uint8_t rpl_max_routing_entries;
ipv6_addr_t my_address;
@ -80,16 +81,10 @@ uint8_t rpl_init(int if_id)
rpl_instances_init();
/* initialize routing table */
#if RPL_MAX_ROUTING_ENTRIES != 0
rpl_max_routing_entries = RPL_MAX_ROUTING_ENTRIES;
rpl_clear_routing_table();
if (rpl_routing_table == NULL) {
DEBUGF("Routing table init failed!\n");
return SIXLOWERROR_NULLPTR;
}
else {
DEBUGF("Routing table init finished!\n");
}
#endif
init_trickle();
rpl_process_pid = thread_create(rpl_process_buf, RPL_PROCESS_STACKSIZE,
@ -223,6 +218,7 @@ void *rpl_process(void *arg)
}
}
}
#if RPL_MAX_ROUTING_ENTRIES != 0
else {
srh_header = rpl_get_srh_header(ipv6_buf);
@ -231,7 +227,7 @@ void *rpl_process(void *arg)
rpl_srh_sendto(payload, NTOHS(ipv6_buf->length), &ipv6_buf->srcaddr, &ipv6_buf->destaddr, srh_header, srh_header->hdrextlen + sizeof(ipv6_srh_t));
}
}
#endif
}
#endif
@ -316,6 +312,7 @@ ipv6_addr_t *rpl_get_next_hop(ipv6_addr_t *addr)
DEBUGF("Looking up the next hop to %s\n", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, addr));
#if RPL_MAX_ROUTING_ENTRIES != 0
for (uint8_t i = 0; i < rpl_max_routing_entries; i++) {
if (rpl_routing_table[i].used) {
DEBUGF("checking %d: %s\n", i, ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN, &rpl_routing_table[i].address));
@ -334,10 +331,14 @@ ipv6_addr_t *rpl_get_next_hop(ipv6_addr_t *addr)
}
}
}
#else
(void) addr;
#endif
return (rpl_get_my_preferred_parent());
}
#if RPL_MAX_ROUTING_ENTRIES != 0
void rpl_add_routing_entry(ipv6_addr_t *addr, ipv6_addr_t *next_hop, uint16_t lifetime)
{
rpl_routing_entry_t *entry = rpl_find_routing_entry(addr);
@ -359,7 +360,9 @@ void rpl_add_routing_entry(ipv6_addr_t *addr, ipv6_addr_t *next_hop, uint16_t li
}
}
}
#endif
#if RPL_MAX_ROUTING_ENTRIES != 0
void rpl_del_routing_entry(ipv6_addr_t *addr)
{
@ -372,7 +375,9 @@ void rpl_del_routing_entry(ipv6_addr_t *addr)
}
}
}
#endif
#if RPL_MAX_ROUTING_ENTRIES != 0
rpl_routing_entry_t *rpl_find_routing_entry(ipv6_addr_t *addr)
{
@ -386,7 +391,9 @@ rpl_routing_entry_t *rpl_find_routing_entry(ipv6_addr_t *addr)
return NULL;
}
#endif
#if RPL_MAX_ROUTING_ENTRIES != 0
void rpl_clear_routing_table(void)
{
@ -394,15 +401,21 @@ void rpl_clear_routing_table(void)
memset(&rpl_routing_table[i], 0, sizeof(rpl_routing_table[i]));
}
}
#endif
rpl_routing_entry_t *rpl_get_routing_table(void)
{
#if RPL_MAX_ROUTING_ENTRIES != 0
return rpl_routing_table;
#else
return NULL;
#endif
}
#if RPL_DEFAULT_MOP == RPL_NON_STORING_MODE
/* everything from here on is non-storing mode related */
#if RPL_MAX_ROUTING_ENTRIES != 0
void rpl_add_srh_entry(ipv6_addr_t *child, ipv6_addr_t *parent, uint16_t lifetime)
{
@ -440,6 +453,7 @@ void rpl_add_srh_entry(ipv6_addr_t *child, ipv6_addr_t *parent, uint16_t lifetim
}
}
}
#endif
/**
* @brief Checks if two IPv6 host suffixes are equal.
@ -455,6 +469,7 @@ int ipv6_suffix_is_equal(const ipv6_addr_t *a, const ipv6_addr_t *b)
(a->uint32[3] == b->uint32[3]);
}
#if RPL_MAX_ROUTING_ENTRIES != 0
ipv6_srh_t *rpl_get_srh_header(ipv6_hdr_t *act_ipv6_hdr)
{
uint8_t route_length = RPL_MAX_SRH_PATH_LENGTH;
@ -523,6 +538,7 @@ ipv6_srh_t *rpl_get_srh_header(ipv6_hdr_t *act_ipv6_hdr)
/* set the destination-address in ipv6-buf->destaddr, which is the pointer of child */
return srh_header;
}
#endif
void rpl_remove_srh_header(ipv6_hdr_t *ipv6_header, const void *buf, uint8_t nextheader)
{

View File

@ -674,7 +674,7 @@ void rpl_recv_DAO_mode(void)
&rpl_opt_target_buf->target));
DEBUGF("Transit: %s\n", ipv6_addr_to_str(addr_str_mode, IPV6_MAX_ADDR_STR_LEN,
&rpl_opt_transit_buf->parent));
#if RPL_DEFAULT_MOP == RPL_NON_STORING_MODE
#if (RPL_DEFAULT_MOP == RPL_NON_STORING_MODE) && (RPL_MAX_ROUTING_ENTRIES != 0)
rpl_add_srh_entry(&rpl_opt_target_buf->target, &rpl_opt_transit_buf->parent,
rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit);
#endif

View File

@ -691,12 +691,14 @@ void rpl_recv_DAO_mode(void)
len += rpl_opt_transit_buf->length;
/* route lifetime seconds = (DAO lifetime) * (Unit Lifetime) */
#if RPL_MAX_ROUTING_ENTRIES != 0
DEBUG("Adding routing information: Target: %s, Source: %s, Lifetime: %u\n",
ipv6_addr_to_str(addr_str_mode, IPV6_MAX_ADDR_STR_LEN, &rpl_opt_target_buf->target),
ipv6_addr_to_str(addr_str_mode, IPV6_MAX_ADDR_STR_LEN, &ipv6_buf->srcaddr),
(rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit));
rpl_add_routing_entry(&rpl_opt_target_buf->target, &ipv6_buf->srcaddr,
rpl_opt_transit_buf->path_lifetime * my_dodag->lifetime_unit);
#endif
increment_seq = 1;
break;
}

View File

@ -246,12 +246,15 @@ static void *rt_timer_over(void *arg)
{
(void) arg;
#if RPL_MAX_ROUTING_ENTRIES != 0
rpl_routing_entry_t *rt;
#endif
while (1) {
rpl_dodag_t *my_dodag = rpl_get_my_dodag();
if (my_dodag != NULL) {
#if RPL_MAX_ROUTING_ENTRIES != 0
rt = rpl_get_routing_table();
for (uint8_t i = 0; i < rpl_max_routing_entries; i++) {
@ -264,7 +267,7 @@ static void *rt_timer_over(void *arg)
}
}
}
#endif
/* Parent is NULL for root too */
if (my_dodag->my_preferred_parent != NULL) {
if (my_dodag->my_preferred_parent->lifetime <= 1) {

View File

@ -20,13 +20,15 @@
#include "rpl.h"
#if RPL_MAX_ROUTING_ENTRIES != 0
static char addr_str[IPV6_MAX_ADDR_STR_LEN];
#endif
void _rpl_route_handler(int argc, char **argv)
{
(void) argc;
(void) argv;
#if RPL_MAX_ROUTING_ENTRIES != 0
rpl_routing_entry_t *rtable;
rtable = rpl_get_routing_table();
unsigned c = 0;
@ -48,6 +50,8 @@ void _rpl_route_handler(int argc, char **argv)
}
puts("--------------------------------------------------------------------");
printf(" %u routing table entries\n", c);
#else
puts("No routing table available");
#endif
puts("$");
}