Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / inet / tests / TestInetCommonOptions.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2013-2017 Nest Labs, Inc.
5  *    All rights reserved.
6  *
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
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 /**
21  *    @file
22  *      Common command-line option handling code for test applications.
23  *
24  */
25
26 #pragma once
27
28 #include <vector>
29
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>
35
36 #define TOOL_OPTIONS_ENV_VAR_NAME "CHIP_INET_TEST_OPTIONS"
37
38 enum
39 {
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,
52 };
53
54 /**
55  * Handler for options that control local network/network interface configuration.
56  */
57 class NetworkOptions : public chip::ArgParser::OptionSetBase
58 {
59 public:
60     std::vector<chip::Inet::IPAddress> LocalIPv4Addr;
61     std::vector<chip::Inet::IPAddress> LocalIPv6Addr;
62
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;
69     uint32_t EventDelay;
70     bool TapUseSystemConfig;
71 #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
72
73     NetworkOptions();
74
75     bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) override;
76 };
77
78 extern NetworkOptions gNetworkOptions;
79
80 /**
81  * Handler for options that control fault injection testing behavior.
82  */
83 class FaultInjectionOptions : public chip::ArgParser::OptionSetBase
84 {
85 public:
86     uint32_t TestIterations;
87     bool DebugResourceUsage;
88     bool PrintFaultCounters;
89     uint32_t ExtraCleanupTimeMsec;
90
91     FaultInjectionOptions();
92
93     bool HandleOption(const char * progName, OptionSet * optSet, int id, const char * name, const char * arg) override;
94 };
95
96 extern FaultInjectionOptions gFaultInjectionOptions;