• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2019, The OpenThread Authors.
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *  1. Redistributions of source code must retain the above copyright
8  *     notice, this list of conditions and the following disclaimer.
9  *  2. Redistributions in binary form must reproduce the above copyright
10  *     notice, this list of conditions and the following disclaimer in the
11  *     documentation and/or other materials provided with the distribution.
12  *  3. Neither the name of the copyright holder nor the
13  *     names of its contributors may be used to endorse or promote products
14  *     derived from this software without specific prior written permission.
15  *
16  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  *  POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /**
30  * @file
31  *   This file includes compile-time configurations for the CLI service.
32  */
33 
34 #ifndef CONFIG_CLI_H_
35 #define CONFIG_CLI_H_
36 
37 #include "openthread-core-config.h"
38 
39 #include <openthread/tcp.h>
40 
41 #ifndef OPENTHREAD_POSIX
42 #if defined(__ANDROID__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || \
43     defined(__unix__)
44 #define OPENTHREAD_POSIX 1
45 #else
46 #define OPENTHREAD_POSIX 0
47 #endif
48 #endif
49 
50 /**
51  * @def OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
52  *
53  * The maximum size of the CLI line in bytes including the null terminator.
54  */
55 #ifndef OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
56 #define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 384
57 #endif
58 
59 /**
60  * @def OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
61  *
62  * Indicates whether TCAT should be enabled in the CLI tool.
63  */
64 #ifndef OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
65 #define OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE 1
66 #endif
67 
68 /**
69  * @def OPENTHREAD_CONFIG_CLI_TCP_ENABLE
70  *
71  * Indicates whether TCP should be enabled in the CLI tool.
72  */
73 #ifndef OPENTHREAD_CONFIG_CLI_TCP_ENABLE
74 #define OPENTHREAD_CONFIG_CLI_TCP_ENABLE 1
75 #endif
76 
77 /**
78  * @def OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE
79  *
80  * The number of bytes to transfer for the TCP benchmark in the CLI.
81  */
82 #ifndef OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE
83 #define OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE (72 << 10)
84 #endif
85 
86 /**
87  * @def OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE
88  *
89  * The size of memory used for the TCP receive buffer, in bytes.
90  */
91 #ifndef OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE
92 #define OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS
93 #endif
94 
95 /**
96  * @def OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES
97  *
98  * The maximum number of user CLI command lists that can be registered by the interpreter.
99  */
100 #ifndef OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES
101 #define OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES 1
102 #endif
103 
104 /**
105  * @def OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE
106  *
107  * Indicates whether or not an externally provided list of cli commands is defined.
108  *
109  * This is to be used only when `OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES` is greater than 1.
110  */
111 #ifndef OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE
112 #define OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE 0
113 #endif
114 
115 /**
116  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE
117  *
118  * Define as 1 for CLI to emit its command input string and the resulting output to the logs.
119  *
120  * By default this is enabled on any POSIX based platform (`OPENTHREAD_POSIX`) and only when CLI itself is not being
121  * used for logging.
122  */
123 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE
124 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE \
125     (OPENTHREAD_POSIX && (OPENTHREAD_CONFIG_LOG_OUTPUT != OPENTHREAD_CONFIG_LOG_OUTPUT_APP))
126 #endif
127 
128 /**
129  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL
130  *
131  * Defines the log level to use when CLI emits its command input/output to the logs.
132  *
133  * This is used only when `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled.
134  */
135 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL
136 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL OT_LOG_LEVEL_DEBG
137 #endif
138 
139 /**
140  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE
141  *
142  * The log string buffer size (in bytes).
143  *
144  * This is only used when `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled.
145  */
146 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE
147 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
148 #endif
149 
150 /**
151  * @def OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE
152  *
153  * Enable CLI prompt.
154  *
155  * When enabled, the CLI will print prompt on the output after processing a command.
156  * Otherwise, no prompt is added to the output.
157  */
158 #ifndef OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE
159 #define OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE 1
160 #endif
161 
162 /**
163  * @def OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE
164  *
165  * Specifies the max TXT record data length to use when performing DNS queries.
166  *
167  * If the service TXT record data length is greater than the specified value, it will be read partially (up to the given
168  * size) and output as a sequence of raw hex bytes `[{hex-bytes}...]`
169  */
170 #ifndef OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE
171 #define OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE 512
172 #endif
173 
174 /**
175  * @def OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK
176  *
177  * Define as 1 to have CLI register an IPv6 receive callback using `otIp6SetReceiveCallback()`.
178  *
179  * This is intended for testing only. Receive callback should be registered for the `otIp6GetBorderRoutingCounters()`
180  * to count the messages being passed to the callback.
181  */
182 #ifndef OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK
183 #define OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK 0
184 #endif
185 
186 /**
187  * @def OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
188  *
189  * Define to 1 to enable BLE secure support.
190  */
191 #ifndef OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
192 #define OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE 0
193 #endif
194 
195 #endif // CONFIG_CLI_H_
196