mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
shell: added RPL route shell command
This commit is contained in:
parent
7c7e24fe53
commit
0018e3a181
@ -25,6 +25,9 @@ endif
|
||||
ifneq (,$(filter ps,$(USEMODULE)))
|
||||
SRC += sc_ps.c
|
||||
endif
|
||||
ifneq (,$(filter rpl,$(USEMODULE)))
|
||||
SRC += sc_rpl.c
|
||||
endif
|
||||
ifneq (,$(filter rtc,$(USEMODULE)))
|
||||
SRC += sc_rtc.c
|
||||
endif
|
||||
|
53
sys/shell/commands/sc_rpl.c
Normal file
53
sys/shell/commands/sc_rpl.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup shell_commands
|
||||
* @{
|
||||
* @file sc_rpl.c
|
||||
* @brief provides shell commands to manage and query RPL
|
||||
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "rpl.h"
|
||||
|
||||
static char addr_str[IPV6_MAX_ADDR_STR_LEN];
|
||||
|
||||
void _rpl_route_handler(int argc, char **argv)
|
||||
{
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
|
||||
rpl_routing_entry_t *rtable;
|
||||
rtable = rpl_get_routing_table();
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
puts("--------------------------------------------------------------------");
|
||||
printf(" %d routing table entries\n", c);
|
||||
|
||||
puts("$");
|
||||
}
|
@ -104,6 +104,10 @@ extern void _transceiver_set_ignore_handler(int argc, char **argv);
|
||||
extern void _net_if_ifconfig(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_RPL
|
||||
extern void _rpl_route_handler(int argc, char **argv);
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_MCI
|
||||
extern void _get_sectorsize(int argc, char **argv);
|
||||
extern void _get_blocksize(int argc, char **argv);
|
||||
@ -172,6 +176,9 @@ const shell_command_t _shell_command_list[] = {
|
||||
#ifdef MODULE_NET_IF
|
||||
{"ifconfig", "Configures a network interface", _net_if_ifconfig},
|
||||
#endif
|
||||
#ifdef MODULE_RPL
|
||||
{"route", "Shows the routing table", _rpl_route_handler},
|
||||
#endif
|
||||
#ifdef MODULE_MCI
|
||||
{DISK_READ_SECTOR_CMD, "Reads the specified sector of inserted memory card", _read_sector},
|
||||
{DISK_READ_BYTES_CMD, "Reads the specified bytes from inserted memory card", _read_bytes},
|
||||
|
Loading…
Reference in New Issue
Block a user