1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-17 18:43:50 +01:00
RIOT/sys/shell/cmds/gnrc_ipv6_blacklist.c
Marian Buschsieweke c06335b71b
sys/shell: make cmds submodules
Previously `shell_commands` was a "catch-all" module that included
shell commands for each and every used module that has a shell
companion. Instead, the new `shell_cmds` module is now used to provide
shell commands as individually selectable submodules, e.g.
`cmd_gnrc_icmpv6_echo` now provides the ICMPv6 echo command (a.k.a.
ping).

To still have a "catch all" module to pull in shell commands of modules
already used, `shell_cmds_default` was introduced. `shell_commands`
depends now on `shell_cmds_default` for backward compatibility, but
has been deprecated. New apps should use `shell_cmds_default`
instead.

For a handful of shell commands individual selection was already
possible. Those modules now depend on the corresponding `cmd_%` module
and they have been deprecated.
2022-09-16 13:15:45 +02:00

69 lines
1.6 KiB
C

/*
* Copyright (C) Freie Universität Berlin
*
* 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.
*/
/**
* @{
*
* @file
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Martin Landsmann <martin.landsmann@haw-hamburg.de>
*/
#include <stdio.h>
#include <string.h>
#include "net/gnrc/ipv6/blacklist.h"
#include "shell.h"
static void _usage(char *cmd)
{
printf("usage: * %s\n", cmd);
puts(" Lists all addresses in the blacklist.");
printf(" * %s add <addr>\n", cmd);
puts(" Adds <addr> to the blacklist.");
printf(" * %s del <addr>\n", cmd);
puts(" Deletes <addr> from the blacklist.");
printf(" * %s help\n", cmd);
puts(" Print this.");
}
static int _blacklist(int argc, char **argv)
{
ipv6_addr_t addr;
if (argc < 2) {
gnrc_ipv6_blacklist_print();
return 0;
}
else if (argc > 2) {
if (ipv6_addr_from_str(&addr, argv[2]) == NULL) {
_usage(argv[0]);
return 1;
}
}
if (strcmp("add", argv[1]) == 0) {
gnrc_ipv6_blacklist_add(&addr);
}
else if (strcmp("del", argv[1]) == 0) {
gnrc_ipv6_blacklist_del(&addr);
}
else if (strcmp("help", argv[1]) == 0) {
_usage(argv[0]);
}
else {
_usage(argv[0]);
return 1;
}
return 0;
}
SHELL_COMMAND(blacklist,
"blacklists an address for receival ('blacklist [add|del|help]')",
_blacklist);
/** @} */