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 
35 #ifndef CONFIG_CLI_H_
36 #define CONFIG_CLI_H_
37 
38 #include "openthread-core-config.h"
39 
40 #include <openthread/tcp.h>
41 
42 #ifndef OPENTHREAD_POSIX
43 #if defined(__ANDROID__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__linux__) || defined(__NetBSD__) || \
44     defined(__unix__)
45 #define OPENTHREAD_POSIX 1
46 #else
47 #define OPENTHREAD_POSIX 0
48 #endif
49 #endif
50 
51 /**
52  * @def OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
53  *
54  * The maximum size of the CLI line in bytes including the null terminator.
55  *
56  */
57 #ifndef OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
58 #define OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH 384
59 #endif
60 
61 /**
62  * @def OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
63  *
64  * Indicates whether TCAT should be enabled in the CLI tool.
65  *
66  */
67 #ifndef OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
68 #define OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE 1
69 #endif
70 
71 /**
72  * @def OPENTHREAD_CONFIG_CLI_TCP_ENABLE
73  *
74  * Indicates whether TCP should be enabled in the CLI tool.
75  *
76  */
77 #ifndef OPENTHREAD_CONFIG_CLI_TCP_ENABLE
78 #define OPENTHREAD_CONFIG_CLI_TCP_ENABLE 1
79 #endif
80 
81 /**
82  * @def OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE
83  *
84  * The number of bytes to transfer for the TCP benchmark in the CLI.
85  *
86  */
87 #ifndef OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE
88 #define OPENTHREAD_CONFIG_CLI_TCP_DEFAULT_BENCHMARK_SIZE (72 << 10)
89 #endif
90 
91 /**
92  * @def OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE
93  *
94  * The size of memory used for the TCP receive buffer, in bytes.
95  */
96 #ifndef OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE
97 #define OPENTHREAD_CONFIG_CLI_TCP_RECEIVE_BUFFER_SIZE OT_TCP_RECEIVE_BUFFER_SIZE_FEW_HOPS
98 #endif
99 
100 /**
101  * @def OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES
102  *
103  * The maximum number of user CLI command lists that can be registered by the interpreter.
104  *
105  */
106 #ifndef OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES
107 #define OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES 1
108 #endif
109 
110 /**
111  * @def OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE
112  *
113  * Indicates whether or not an externally provided list of cli commands is defined.
114  *
115  * This is to be used only when `OPENTHREAD_CONFIG_CLI_MAX_USER_CMD_ENTRIES` is greater than 1.
116  *
117  */
118 #ifndef OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE
119 #define OPENTHREAD_CONFIG_CLI_VENDOR_COMMANDS_ENABLE 0
120 #endif
121 
122 /**
123  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE
124  *
125  * Define as 1 for CLI to emit its command input string and the resulting output to the logs.
126  *
127  * By default this is enabled on any POSIX based platform (`OPENTHREAD_POSIX`) and only when CLI itself is not being
128  * used for logging.
129  *
130  */
131 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE
132 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE \
133     (OPENTHREAD_POSIX && (OPENTHREAD_CONFIG_LOG_OUTPUT != OPENTHREAD_CONFIG_LOG_OUTPUT_APP))
134 #endif
135 
136 /**
137  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL
138  *
139  * Defines the log level to use when CLI emits its command input/output to the logs.
140  *
141  * This is used only when `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled.
142  *
143  */
144 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL
145 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LEVEL OT_LOG_LEVEL_DEBG
146 #endif
147 
148 /**
149  * @def OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE
150  *
151  * The log string buffer size (in bytes).
152  *
153  * This is only used when `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE` is enabled.
154  *
155  */
156 #ifndef OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE
157 #define OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_LOG_STRING_SIZE OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH
158 #endif
159 
160 /**
161  * @def OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE
162  *
163  * Enable CLI prompt.
164  *
165  * When enabled, the CLI will print prompt on the output after processing a command.
166  * Otherwise, no prompt is added to the output.
167  *
168  */
169 #ifndef OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE
170 #define OPENTHREAD_CONFIG_CLI_PROMPT_ENABLE 1
171 #endif
172 
173 /**
174  * @def OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE
175  *
176  * Specifies the max TXT record data length to use when performing DNS queries.
177  *
178  * If the service TXT record data length is greater than the specified value, it will be read partially (up to the given
179  * size) and output as a sequence of raw hex bytes `[{hex-bytes}...]`
180  *
181  */
182 #ifndef OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE
183 #define OPENTHREAD_CONFIG_CLI_TXT_RECORD_MAX_SIZE 512
184 #endif
185 
186 /**
187  * @def OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK
188  *
189  * Define as 1 to have CLI register an IPv6 receive callback using `otIp6SetReceiveCallback()`.
190  *
191  * This is intended for testing only. Receive callback should be registered for the `otIp6GetBorderRoutingCounters()`
192  * to count the messages being passed to the callback.
193  *
194  */
195 #ifndef OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK
196 #define OPENTHREAD_CONFIG_CLI_REGISTER_IP6_RECV_CALLBACK 0
197 #endif
198 
199 /**
200  * @def OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
201  *
202  * Define to 1 to enable BLE secure support.
203  *
204  */
205 #ifndef OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE
206 #define OPENTHREAD_CONFIG_CLI_BLE_SECURE_ENABLE 0
207 #endif
208 
209 #endif // CONFIG_CLI_H_
210