mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-26 15:03:53 +01:00
Merge pull request #14652 from akshaim/Kconfig_netif
net/netif : Expose configurations to Kconfig
This commit is contained in:
commit
7f1f8ae576
@ -43,11 +43,17 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum length for an interface name
|
||||
* @defgroup net_netif_conf Network interfaces compile configurations
|
||||
* @ingroup config
|
||||
* @{
|
||||
*/
|
||||
#ifndef NETIF_NAMELENMAX
|
||||
#define NETIF_NAMELENMAX (8U)
|
||||
/**
|
||||
* @brief Maximum length for an interface name
|
||||
*/
|
||||
#ifndef CONFIG_NETIF_NAMELENMAX
|
||||
#define CONFIG_NETIF_NAMELENMAX (8U)
|
||||
#endif
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief Network interface descriptor.
|
||||
@ -75,14 +81,14 @@ netif_t *netif_iter(netif_t *last);
|
||||
* @brief Gets name of an interface
|
||||
*
|
||||
* @pre `name != NULL`
|
||||
* @pre name holds at least @ref NETIF_NAMELENMAX characters
|
||||
* @pre name holds at least @ref CONFIG_NETIF_NAMELENMAX characters
|
||||
*
|
||||
* @note Supposed to be implemented by the networking module. `name` must be
|
||||
* zero-terminated in the result!
|
||||
*
|
||||
* @param[in] netif A network interface.
|
||||
* @param[out] name The name of the interface. Must not be `NULL`. Must at least
|
||||
* hold @ref NETIF_NAMELENMAX bytes.
|
||||
* hold @ref CONFIG_NETIF_NAMELENMAX bytes.
|
||||
*
|
||||
* @return length of @p name on success
|
||||
*/
|
||||
|
||||
@ -11,5 +11,6 @@ rsource "credman/Kconfig"
|
||||
rsource "gnrc/Kconfig"
|
||||
rsource "sock/Kconfig"
|
||||
rsource "link_layer/Kconfig"
|
||||
rsource "netif/Kconfig"
|
||||
|
||||
endmenu # Networking
|
||||
|
||||
19
sys/net/netif/Kconfig
Normal file
19
sys/net/netif/Kconfig
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2020 Freie Universitaet 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.
|
||||
#
|
||||
menuconfig KCONFIG_MODULE_NETIF
|
||||
bool "Configure Network Interfaces"
|
||||
depends on MODULE_NETIF
|
||||
help
|
||||
Configure Network Interfaces (NETIF) using Kconfig.
|
||||
|
||||
if KCONFIG_MODULE_NETIF
|
||||
|
||||
config NETIF_NAMELENMAX
|
||||
int "Maximum length for an interface name"
|
||||
default 8
|
||||
|
||||
endif # KCONFIG_MODULE_NETIF
|
||||
@ -56,11 +56,11 @@ netif_t *netif_get_by_name(const char *name)
|
||||
assert(name);
|
||||
list_node_t *node = netif_list.next;
|
||||
|
||||
char tmp[NETIF_NAMELENMAX];
|
||||
char tmp[CONFIG_NETIF_NAMELENMAX];
|
||||
|
||||
while(node) {
|
||||
netif_get_name((netif_t *)node, tmp);
|
||||
if(strncmp(name, tmp, NETIF_NAMELENMAX) == 0) {
|
||||
if(strncmp(name, tmp, CONFIG_NETIF_NAMELENMAX) == 0) {
|
||||
return (netif_t *)node;
|
||||
}
|
||||
node = node->next;
|
||||
|
||||
@ -82,7 +82,7 @@ static const struct {
|
||||
/* utility functions */
|
||||
static void _print_iface_name(netif_t *iface)
|
||||
{
|
||||
char name[NETIF_NAMELENMAX];
|
||||
char name[CONFIG_NETIF_NAMELENMAX];
|
||||
netif_get_name(iface, name);
|
||||
printf("%s", name);
|
||||
}
|
||||
|
||||
@ -1117,8 +1117,8 @@ static void test_netif_iter(void)
|
||||
|
||||
static void test_netif_get_name(void)
|
||||
{
|
||||
char exp_name[NETIF_NAMELENMAX + 1];
|
||||
char name[NETIF_NAMELENMAX];
|
||||
char exp_name[CONFIG_NETIF_NAMELENMAX + 1];
|
||||
char name[CONFIG_NETIF_NAMELENMAX];
|
||||
int res;
|
||||
netif_t *netif = netif_iter(NULL);
|
||||
/* there must be at least one interface */
|
||||
@ -1132,7 +1132,7 @@ static void test_netif_get_name(void)
|
||||
|
||||
static void test_netif_get_by_name(void)
|
||||
{
|
||||
char name[NETIF_NAMELENMAX] = "6nPRK28";
|
||||
char name[CONFIG_NETIF_NAMELENMAX] = "6nPRK28";
|
||||
netif_t *netif = netif_iter(NULL);
|
||||
|
||||
TEST_ASSERT(netif_get_by_name(name) == NULL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user