3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2013-2017 Nest Labs, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 * Common command-line option handling code for test applications.
30 #include <core/CHIPCore.h>
31 #include <inet/InetArgParser.h>
32 #include <inet/InetLayer.h>
33 #include <support/CHIPArgParser.hpp>
34 #include <system/SystemLayer.h>
36 #define TOOL_OPTIONS_ENV_VAR_NAME "CHIP_INET_TEST_OPTIONS"
40 kToolCommonOpt_NodeAddr = 1000,
41 kToolCommonOpt_EventDelay,
42 kToolCommonOpt_FaultInjection,
43 kToolCommonOpt_FaultTestIterations,
44 kToolCommonOpt_DebugResourceUsage,
45 kToolCommonOpt_PrintFaultCounters,
46 kToolCommonOpt_ExtraCleanupTime,
47 kToolCommonOpt_DebugLwIP,
48 kToolCommonOpt_IPv4GatewayAddr,
49 kToolCommonOpt_IPv6GatewayAddr,
50 kToolCommonOpt_TapDevice,
51 kToolCommonOpt_TapInterfaceConfig,
55 * Handler for options that control local network/network interface configuration.
57 class NetworkOptions : public chip::ArgParser::OptionSetBase
60 std::vector<chip::Inet::IPAddress> LocalIPv4Addr;
61 std::vector<chip::Inet::IPAddress> LocalIPv6Addr;
63 #if CHIP_SYSTEM_CONFIG_USE_LWIP
64 std::vector<chip::Inet::IPAddress> IPv4GatewayAddr;
65 std::vector<chip::Inet::IPAddress> IPv6GatewayAddr;
66 chip::Inet::IPAddress DNSServerAddr;
67 std::vector<const char *> TapDeviceName;
68 uint8_t LwIPDebugFlags;
70 bool TapUseSystemConfig;
71 #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
75 bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) override;
78 extern NetworkOptions gNetworkOptions;
81 * Handler for options that control fault injection testing behavior.
83 class FaultInjectionOptions : public chip::ArgParser::OptionSetBase
86 uint32_t TestIterations;
87 bool DebugResourceUsage;
88 bool PrintFaultCounters;
89 uint32_t ExtraCleanupTimeMsec;
91 FaultInjectionOptions();
93 bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) override;
96 extern FaultInjectionOptions gFaultInjectionOptions;