From da93f311e3368cdbe0ffb0328e0020bd75bdb61f Mon Sep 17 00:00:00 2001 From: Marcin K Szczodrak Date: Mon, 1 Aug 2016 14:59:50 -0700 Subject: [PATCH] add support for project specific OT core config (#319) --- src/core/Makefile.am | 1 + src/core/openthread-core-config.h | 178 +----------------- src/core/openthread-core-default-config.h | 213 ++++++++++++++++++++++ 3 files changed, 223 insertions(+), 169 deletions(-) create mode 100644 src/core/openthread-core-default-config.h diff --git a/src/core/Makefile.am b/src/core/Makefile.am index b32c2cecc..b6cff6f1f 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -72,6 +72,7 @@ libopenthread_a_SOURCES = \ noinst_HEADERS = \ openthread-core-config.h \ + openthread-core-default-config.h \ coap/coap_header.hpp \ coap/coap_server.hpp \ common/code_utils.hpp \ diff --git a/src/core/openthread-core-config.h b/src/core/openthread-core-config.h index e825781b8..8d0721202 100644 --- a/src/core/openthread-core-config.h +++ b/src/core/openthread-core-config.h @@ -34,179 +34,19 @@ #ifndef OPENTHREAD_CORE_CONFIG_H_ #define OPENTHREAD_CORE_CONFIG_H_ -/** - * @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS - * - * The number of message buffers in the buffer pool. - * - */ -#ifndef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS -#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 64 -#endif // OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS +#ifndef OPENTHREAD_CORE_HAVE_PROJECT_SPECIFIC_CONFIG +#define OPENTHREAD_CORE_HAVE_PROJECT_SPECIFIC_CONFIG 0 +#endif -/** - * @def OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE - * - * The size of a message buffer in bytes. - * - */ -#ifndef OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE -#define OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE 128 -#endif // OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE +#define OPENTHREAD_CORE_CONFIG_H_IN -/** - * @def OPENTHREAD_CONFIG_DEFAULT_CHANNEL - * - * The default IEEE 802.15.4 channel. - * - */ -#ifndef OPENTHREAD_CONFIG_DEFAULT_CHANNEL -#define OPENTHREAD_CONFIG_DEFAULT_CHANNEL 11 -#endif // OPENTHREAD_CONFIG_DEFAULT_CHANNEL +#if OPENTHREAD_CORE_HAVE_PROJECT_SPECIFIC_CONFIG +#include +#endif -/** - * @def OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD - * - * The Data Poll period during attach in milliseconds. - * - */ -#ifndef OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD -#define OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD 100 -#endif // OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD +#include -/** - * @def OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES - * - * The number of EID-to-RLOC cache entries. - * - */ -#ifndef OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES -#define OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES 8 -#endif // OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES - -/** - * @def OPENTHREAD_CONFIG_MAX_CHILDREN - * - * The maximum number of children. - * - */ -#ifndef OPENTHREAD_CONFIG_MAX_CHILDREN -#define OPENTHREAD_CONFIG_MAX_CHILDREN 5 -#endif // OPENTHREAD_CONFIG_MAX_CHILDREN - -/** - * @def OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD - * - * The minimum number of supported IPv6 address registrations per child. - * - */ -#ifndef OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD -#define OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD 4 -#endif // OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD - -/** - * @def OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT - * - * The 6LoWPAN fragment reassembly timeout in seconds. - * - */ -#ifndef OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT -#define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 5 -#endif // OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT - -/** - * @def OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES - * - * The number of MPL cache entries for duplicate detection. - * - */ -#ifndef OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES -#define OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES 32 -#endif // OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES - -/** - * @def OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME - * - * The MPL cache entry lifetime in seconds. - * - */ -#ifndef OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME -#define OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME 5 -#endif // OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME - -/** - * @def OPENTHREAD_CONFIG_LOG_LEVEL - * - * The log level. - * - */ -#ifndef OPENTHREAD_CONFIG_LOG_LEVEL -#define OPENTHREAD_CONFIG_LOG_LEVEL OPENTHREAD_LOG_LEVEL_CRIT -#endif // OPENTHREAD_CONFIG_LOG_LEVEL - -/** - * @def OPENTHREAD_CONFIG_LOG_API - * - * Define to enable OpenThread API logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_API - -/** - * @def OPENTHREAD_CONFIG_LOG_MLE - * - * Define to enable MLE logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_MLE - -/** - * @def OPENTHREAD_CONFIG_LOG_ARP - * - * Define to enable EID-to-RLOC map logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_ARP - -/** - * @def OPENTHREAD_CONFIG_LOG_NETDATA - * - * Define to enable Network Data logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_NETDATA - -/** - * @def OPENTHREAD_CONFIG_LOG_ICMP - * - * Define to enable ICMPv6 logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_ICMP - -/** - * @def OPENTHREAD_CONFIG_LOG_IP6 - * - * Define to enable IPv6 logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_IP6 - -/** - * @def OPENTHREAD_CONFIG_LOG_MAC - * - * Define to enable IEEE 802.15.4 MAC logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_MAC - -/** - * @def OPENTHREAD_CONFIG_LOG_MEM - * - * Define to enable memory logging. - * - */ -#define OPENTHREAD_CONFIG_LOG_MEM +#undef OPENTHREAD_CORE_CONFIG_H_IN #endif // OPENTHREAD_CORE_CONFIG_H_ diff --git a/src/core/openthread-core-default-config.h b/src/core/openthread-core-default-config.h new file mode 100644 index 000000000..5abb9b911 --- /dev/null +++ b/src/core/openthread-core-default-config.h @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2016, Nest Labs, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file + * This file includes default compile-time configuration constants + * for OpenThread. + */ + +#ifndef OPENTHREAD_CORE_DEFAULT_CONFIG_H_ +#define OPENTHREAD_CORE_DEFAULT_CONFIG_H_ + +/** + * @def OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS + * + * The number of message buffers in the buffer pool. + * + */ +#ifndef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS +#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 64 +#endif // OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS + +/** + * @def OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE + * + * The size of a message buffer in bytes. + * + */ +#ifndef OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE +#define OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE 128 +#endif // OPENTHREAD_CONFIG_MESSAGE_BUFFER_SIZE + +/** + * @def OPENTHREAD_CONFIG_DEFAULT_CHANNEL + * + * The default IEEE 802.15.4 channel. + * + */ +#ifndef OPENTHREAD_CONFIG_DEFAULT_CHANNEL +#define OPENTHREAD_CONFIG_DEFAULT_CHANNEL 11 +#endif // OPENTHREAD_CONFIG_DEFAULT_CHANNEL + +/** + * @def OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD + * + * The Data Poll period during attach in milliseconds. + * + */ +#ifndef OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD +#define OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD 100 +#endif // OPENTHREAD_CONFIG_ATTACH_DATA_POLL_PERIOD + +/** + * @def OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES + * + * The number of EID-to-RLOC cache entries. + * + */ +#ifndef OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES +#define OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES 8 +#endif // OPENTHREAD_CONFIG_ADDRESS_CACHE_ENTRIES + +/** + * @def OPENTHREAD_CONFIG_MAX_CHILDREN + * + * The maximum number of children. + * + */ +#ifndef OPENTHREAD_CONFIG_MAX_CHILDREN +#define OPENTHREAD_CONFIG_MAX_CHILDREN 5 +#endif // OPENTHREAD_CONFIG_MAX_CHILDREN + +/** + * @def OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD + * + * The minimum number of supported IPv6 address registrations per child. + * + */ +#ifndef OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD +#define OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD 4 +#endif // OPENTHREAD_CONFIG_IP_ADDRS_PER_CHILD + +/** + * @def OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT + * + * The 6LoWPAN fragment reassembly timeout in seconds. + * + */ +#ifndef OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT +#define OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT 5 +#endif // OPENTHREAD_CONFIG_6LOWPAN_REASSEMBLY_TIMEOUT + +/** + * @def OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES + * + * The number of MPL cache entries for duplicate detection. + * + */ +#ifndef OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES +#define OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES 32 +#endif // OPENTHREAD_CONFIG_MPL_CACHE_ENTRIES + +/** + * @def OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME + * + * The MPL cache entry lifetime in seconds. + * + */ +#ifndef OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME +#define OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME 5 +#endif // OPENTHREAD_CONFIG_MPL_CACHE_ENTRY_LIFETIME + +/** + * @def OPENTHREAD_CONFIG_LOG_LEVEL + * + * The log level. + * + */ +#ifndef OPENTHREAD_CONFIG_LOG_LEVEL +#define OPENTHREAD_CONFIG_LOG_LEVEL OPENTHREAD_LOG_LEVEL_CRIT +#endif // OPENTHREAD_CONFIG_LOG_LEVEL + +/** + * @def OPENTHREAD_CONFIG_LOG_API + * + * Define to enable OpenThread API logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_API + +/** + * @def OPENTHREAD_CONFIG_LOG_MLE + * + * Define to enable MLE logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_MLE + +/** + * @def OPENTHREAD_CONFIG_LOG_ARP + * + * Define to enable EID-to-RLOC map logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_ARP + +/** + * @def OPENTHREAD_CONFIG_LOG_NETDATA + * + * Define to enable Network Data logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_NETDATA + +/** + * @def OPENTHREAD_CONFIG_LOG_ICMP + * + * Define to enable ICMPv6 logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_ICMP + +/** + * @def OPENTHREAD_CONFIG_LOG_IP6 + * + * Define to enable IPv6 logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_IP6 + +/** + * @def OPENTHREAD_CONFIG_LOG_MAC + * + * Define to enable IEEE 802.15.4 MAC logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_MAC + +/** + * @def OPENTHREAD_CONFIG_LOG_MEM + * + * Define to enable memory logging. + * + */ +#define OPENTHREAD_CONFIG_LOG_MEM + +#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_ +