Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / inet / tests / TestInetCommon.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  *      This file defines constants, globals and interfaces common to
23  *      and used by all CHP Inet layer library test applications and
24  *      tools.
25  *
26  *      NOTE: These do not comprise a public part of the CHIP API and
27  *            are subject to change without notice.
28  *
29  */
30
31 #pragma once
32
33 #ifndef __STDC_LIMIT_MACROS
34 #define __STDC_LIMIT_MACROS
35 #endif
36
37 #include <ctype.h>
38 #include <time.h>
39
40 #include <sys/time.h>
41
42 #include <inet/InetLayer.h>
43 #include <support/CodeUtils.h>
44 #include <system/SystemLayer.h>
45
46 #define CHIP_TOOL_COPYRIGHT "Copyright (c) 2020 Project CHIP Authors\nAll rights reserved.\n"
47
48 #define INET_FAIL_ERROR(ERR, MSG)                                                                                                  \
49     do                                                                                                                             \
50     {                                                                                                                              \
51         InetFailError((ERR), (MSG));                                                                                               \
52     } while (0)
53
54 extern chip::System::Layer gSystemLayer;
55
56 extern chip::Inet::InetLayer gInet;
57
58 extern bool gDone;
59
60 void InitTestInetCommon();
61 void InitSystemLayer();
62 void ShutdownSystemLayer();
63 void InetFailError(int32_t err, const char * msg);
64
65 void InitNetwork();
66 void ServiceEvents(struct ::timeval & aSleepTime);
67 void ShutdownNetwork();
68 void DumpMemory(const uint8_t * mem, uint32_t len, const char * prefix, uint32_t rowWidth);
69 void DumpMemory(const uint8_t * mem, uint32_t len, const char * prefix);
70
71 inline static void ServiceNetwork(struct ::timeval & aSleepTime)
72 {
73     ServiceEvents(aSleepTime);
74 }