Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / inet / InetFaultInjection.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2016-2017 Nest Labs, Inc.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 /**
20  *    @file
21  *      Header file for the fault-injection utilities for Inet.
22  */
23
24 #pragma once
25
26 #include <inet/InetConfig.h>
27
28 #if INET_CONFIG_TEST && CHIP_WITH_NLFAULTINJECTION
29
30 #include <nlfaultinjection.hpp>
31
32 #include <support/DLLUtil.h>
33
34 #include <system/SystemFaultInjection.h>
35
36 namespace chip {
37 namespace Inet {
38 namespace FaultInjection {
39
40 /**
41  * @brief   Fault injection points
42  *
43  * @details
44  * Each point in the code at which a fault can be injected
45  * is identified by a member of this enum.
46  */
47 typedef enum
48 {
49     kFault_DNSResolverNew,  /**< Fail the allocation of a DNSResolver object */
50     kFault_Send,            /**< Fail sending a message over TCP or UDP */
51     kFault_SendNonCritical, /**< Fail sending a UDP message returning an error considered non-critical by RMP */
52     kFault_NumItems,
53 } InetFaultInjectionID;
54
55 DLL_EXPORT nl::FaultInjection::Manager & GetManager();
56
57 } // namespace FaultInjection
58 } // namespace Inet
59 } // namespace chip
60
61 /**
62  * Execute the statements included if the Inet fault is
63  * to be injected.
64  *
65  * @param[in] aFaultID      An Inet fault-injection id
66  * @param[in] aStatements   Statements to be executed if the fault is enabled.
67  */
68 #define INET_FAULT_INJECT(aFaultID, aStatement) nlFAULT_INJECT(Inet::FaultInjection::GetManager(), aFaultID, aStatement)
69
70 #else // INET_CONFIG_TEST
71
72 #define INET_FAULT_INJECT(aFaultID, aStatement)
73
74 #endif // INET_CONFIG_TEST