Skip to content

Commit

Permalink
Merge pull request #872 from OlegHahm/rpl_route_shell_command
Browse files Browse the repository at this point in the history
sys: net: rpl: added RPL route shell command
  • Loading branch information
miri64 committed May 6, 2014
2 parents cef93bd + 0018e3a commit 48d2ad2
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sys/shell/commands/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions sys/shell/commands/sc_rpl.c
Original file line number Diff line number Diff line change
@@ -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("$");
}
7 changes: 7 additions & 0 deletions sys/shell/commands/shell_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 48d2ad2

Please sign in to comment.