1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #12922 from leandrolanzieri/pr/kconfig_migrate/gnrc/ipv6_blacklisting

Kconfig: Expose gnrc/ipv6/blacklist configurations
This commit is contained in:
José Alamos 2019-12-20 11:32:46 +01:00 committed by GitHub
commit 7d4082a6a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 10 deletions

View File

@ -39,8 +39,8 @@ extern "C" {
/** /**
* Maximum size of the blacklist. * Maximum size of the blacklist.
*/ */
#ifndef GNRC_IPV6_BLACKLIST_SIZE #ifndef CONFIG_GNRC_IPV6_BLACKLIST_SIZE
#define GNRC_IPV6_BLACKLIST_SIZE (8) #define CONFIG_GNRC_IPV6_BLACKLIST_SIZE (8)
#endif #endif
/** @} */ /** @} */

View File

@ -7,6 +7,7 @@
menu "GNRC Network stack" menu "GNRC Network stack"
depends on MODULE_GNRC depends on MODULE_GNRC
rsource "network_layer/ipv6/blacklist/Kconfig"
rsource "network_layer/ipv6/whitelist/Kconfig" rsource "network_layer/ipv6/whitelist/Kconfig"
endmenu # GNRC Network Stack endmenu # GNRC Network Stack

View File

@ -0,0 +1,19 @@
# Copyright (c) 2019 HAW Hamburg
#
# 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.
#
menuconfig KCONFIG_MODULE_GNRC_IPV6_BLACKLIST
bool "Configure GNRC IPv6 Blacklisting"
depends on MODULE_GNRC_IPV6_BLACKLIST
help
Configure GNRC IPv6 Blacklisting module using Kconfig.
if KCONFIG_MODULE_GNRC_IPV6_BLACKLIST
config GNRC_IPV6_BLACKLIST_SIZE
int "Maximum size of the blacklist"
default 8
endif # KCONFIG_MODULE_GNRC_IPV6_BLACKLIST

View File

@ -22,14 +22,14 @@
#define ENABLE_DEBUG (0) #define ENABLE_DEBUG (0)
#include "debug.h" #include "debug.h"
ipv6_addr_t gnrc_ipv6_blacklist[GNRC_IPV6_BLACKLIST_SIZE]; ipv6_addr_t gnrc_ipv6_blacklist[CONFIG_GNRC_IPV6_BLACKLIST_SIZE];
BITFIELD(gnrc_ipv6_blacklist_set, GNRC_IPV6_BLACKLIST_SIZE); BITFIELD(gnrc_ipv6_blacklist_set, CONFIG_GNRC_IPV6_BLACKLIST_SIZE);
static char addr_str[IPV6_ADDR_MAX_STR_LEN]; static char addr_str[IPV6_ADDR_MAX_STR_LEN];
int gnrc_ipv6_blacklist_add(const ipv6_addr_t *addr) int gnrc_ipv6_blacklist_add(const ipv6_addr_t *addr)
{ {
for (int i = 0; i < GNRC_IPV6_BLACKLIST_SIZE; i++) { for (int i = 0; i < CONFIG_GNRC_IPV6_BLACKLIST_SIZE; i++) {
if (!bf_isset(gnrc_ipv6_blacklist_set, i)) { if (!bf_isset(gnrc_ipv6_blacklist_set, i)) {
bf_set(gnrc_ipv6_blacklist_set, i); bf_set(gnrc_ipv6_blacklist_set, i);
memcpy(&gnrc_ipv6_blacklist[i], addr, sizeof(*addr)); memcpy(&gnrc_ipv6_blacklist[i], addr, sizeof(*addr));
@ -43,7 +43,7 @@ int gnrc_ipv6_blacklist_add(const ipv6_addr_t *addr)
void gnrc_ipv6_blacklist_del(const ipv6_addr_t *addr) void gnrc_ipv6_blacklist_del(const ipv6_addr_t *addr)
{ {
for (int i = 0; i < GNRC_IPV6_BLACKLIST_SIZE; i++) { for (int i = 0; i < CONFIG_GNRC_IPV6_BLACKLIST_SIZE; i++) {
if (ipv6_addr_equal(addr, &gnrc_ipv6_blacklist[i])) { if (ipv6_addr_equal(addr, &gnrc_ipv6_blacklist[i])) {
bf_unset(gnrc_ipv6_blacklist_set, i); bf_unset(gnrc_ipv6_blacklist_set, i);
DEBUG("IPv6 blacklist: unblacklisted %s\n", DEBUG("IPv6 blacklist: unblacklisted %s\n",
@ -54,7 +54,7 @@ void gnrc_ipv6_blacklist_del(const ipv6_addr_t *addr)
bool gnrc_ipv6_blacklisted(const ipv6_addr_t *addr) bool gnrc_ipv6_blacklisted(const ipv6_addr_t *addr)
{ {
for (int i = 0; i < GNRC_IPV6_BLACKLIST_SIZE; i++) { for (int i = 0; i < CONFIG_GNRC_IPV6_BLACKLIST_SIZE; i++) {
if (bf_isset(gnrc_ipv6_blacklist_set, i) && if (bf_isset(gnrc_ipv6_blacklist_set, i) &&
ipv6_addr_equal(addr, &gnrc_ipv6_blacklist[i])) { ipv6_addr_equal(addr, &gnrc_ipv6_blacklist[i])) {
return true; return true;

View File

@ -21,13 +21,13 @@
#include "net/gnrc/ipv6/blacklist.h" #include "net/gnrc/ipv6/blacklist.h"
extern ipv6_addr_t gnrc_ipv6_blacklist[GNRC_IPV6_BLACKLIST_SIZE]; extern ipv6_addr_t gnrc_ipv6_blacklist[CONFIG_GNRC_IPV6_BLACKLIST_SIZE];
extern BITFIELD(gnrc_ipv6_blacklist_set, GNRC_IPV6_BLACKLIST_SIZE); extern BITFIELD(gnrc_ipv6_blacklist_set, CONFIG_GNRC_IPV6_BLACKLIST_SIZE);
void gnrc_ipv6_blacklist_print(void) void gnrc_ipv6_blacklist_print(void)
{ {
char addr_str[IPV6_ADDR_MAX_STR_LEN]; char addr_str[IPV6_ADDR_MAX_STR_LEN];
for (int i = 0; i < GNRC_IPV6_BLACKLIST_SIZE; i++) { for (int i = 0; i < CONFIG_GNRC_IPV6_BLACKLIST_SIZE; i++) {
if (bf_isset(gnrc_ipv6_blacklist_set, i)) { if (bf_isset(gnrc_ipv6_blacklist_set, i)) {
puts(ipv6_addr_to_str(addr_str, &gnrc_ipv6_blacklist[i], sizeof(addr_str))); puts(ipv6_addr_to_str(addr_str, &gnrc_ipv6_blacklist[i], sizeof(addr_str)));
} }