2014-03-09 11:01:10 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* 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.
|
2014-03-09 11:01:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-02-12 18:06:34 +01:00
|
|
|
* @ingroup sys_shell_commands
|
2014-03-09 11:01:10 +01:00
|
|
|
* @{
|
2015-02-12 18:06:34 +01:00
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Provides shell commands to manage and query RPL
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
2014-03-09 11:01:10 +01:00
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "rpl.h"
|
|
|
|
|
|
|
|
static char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
2015-01-15 10:56:22 +01:00
|
|
|
|
2015-03-20 08:51:45 +01:00
|
|
|
int _rpl_route_handler(int argc, char **argv)
|
2014-03-09 11:01:10 +01:00
|
|
|
{
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
|
|
|
|
rpl_routing_entry_t *rtable;
|
|
|
|
rtable = rpl_get_routing_table();
|
2015-01-15 10:56:22 +01:00
|
|
|
if (rtable) {
|
|
|
|
unsigned c = 0;
|
|
|
|
puts("--------------------------------------------------------------------");
|
|
|
|
puts("Routing table");
|
|
|
|
printf(" %-3s %-18s %-18s %s\n", "#", "target", "next hop", "lifetime");
|
|
|
|
puts("--------------------------------------------------------------------");
|
|
|
|
|
|
|
|
for (int i = 0; i < rpl_max_routing_entries; i++) {
|
|
|
|
if (rtable[i].used) {
|
|
|
|
c++;
|
|
|
|
printf(" %03d: %-18s ", i, ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
|
|
|
|
(&rtable[i].address)));
|
|
|
|
printf("%-18s ", ipv6_addr_to_str(addr_str, IPV6_MAX_ADDR_STR_LEN,
|
|
|
|
(&rtable[i].next_hop)));
|
|
|
|
printf("%d\n", rtable[i].lifetime);
|
2014-03-09 11:01:10 +01:00
|
|
|
|
2015-01-15 10:56:22 +01:00
|
|
|
}
|
2014-03-09 11:01:10 +01:00
|
|
|
}
|
2015-01-15 10:56:22 +01:00
|
|
|
puts("--------------------------------------------------------------------");
|
|
|
|
printf(" %u routing table entries\n", c);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
puts("No routing table available");
|
2014-03-09 11:01:10 +01:00
|
|
|
}
|
|
|
|
puts("$");
|
2015-03-20 08:51:45 +01:00
|
|
|
|
|
|
|
return 0;
|
2014-03-09 11:01:10 +01:00
|
|
|
}
|