Commit | Line | Data |
---|---|---|
15e8442f JA |
1 | /// @file mobicore.h |
2 | /// @author secunet AG (IKU) | |
3 | /// | |
4 | /// This file is a convenience header file (top-level) including | |
5 | /// all MobiCore-related and platform-specific stuff. | |
6 | ||
7 | #ifndef _INC_MOBICORE_H_ | |
8 | #define _INC_MOBICORE_H_ | |
9 | ||
10 | #if !defined(LINUX) && !defined(ANDROID_ARM) && !defined(WIN32) | |
11 | #error "You MUST define either LINUX or ANDROID_ARM or WIN32" | |
12 | #endif | |
13 | ||
14 | // standard C stuff... | |
15 | ||
16 | #if defined(__cplusplus) && !defined(ANDROID_ARM) | |
17 | #include <string> | |
18 | #include <vector> | |
19 | #include <map> | |
20 | #endif | |
21 | ||
22 | #include <stdlib.h> | |
23 | #include <string.h> | |
24 | #include <stdio.h> | |
25 | #include <stdarg.h> | |
26 | #include <stdbool.h> | |
27 | #include <stdint.h> | |
28 | ||
29 | #ifdef LINUX | |
30 | #include <safemem.h> | |
31 | #endif | |
32 | ||
33 | #if defined(WIN32) && defined(_DEBUG) // enable memory leak detection | |
34 | #define _CRTDBG_MAP_ALLOC | |
35 | #define _CRTDBG_MAP_ALLOC_NEW | |
36 | #include <windows.h> | |
37 | #include <crtdbg.h> | |
38 | #define MYDEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__) | |
39 | #define new MYDEBUG_NEW | |
40 | #endif | |
41 | ||
42 | #ifndef _NO_OPENSSL_INCLUDES | |
43 | ||
44 | // OpenSSL stuff... | |
45 | ||
46 | #include <openssl/rand.h> | |
47 | #include <openssl/sha.h> | |
48 | #include <openssl/aes.h> | |
49 | #include <openssl/rsa.h> | |
50 | #include <openssl/bn.h> | |
51 | #include <openssl/objects.h> | |
52 | #include <openssl/err.h> | |
53 | ||
54 | #endif | |
55 | ||
56 | #ifdef WIN32 | |
57 | ||
58 | #define WIN32_LEAN_AND_MEAN | |
59 | #include <windows.h> | |
60 | ||
61 | #pragma pack(push,4) | |
62 | ||
63 | #pragma warning ( disable : 4200 4996 ) | |
64 | ||
65 | #define GDPUBLIC | |
66 | #define GDAPI __fastcall | |
67 | #define PACK_ATTR | |
68 | #define likely(cond) cond | |
69 | #define unlikely(cond) cond | |
70 | ||
71 | #define bad_read_ptr(_p,_c) IsBadReadPtr((const void *)(_p),(UINT_PTR)(_c)) | |
72 | #define bad_write_ptr(_p,_c) IsBadWritePtr((void *)(_p),(UINT_PTR)(_c)) | |
73 | ||
74 | #define PATH_SEPARATOR "\\" | |
75 | #define PATH_SEP_CHAR '\\' | |
76 | #define DYNLIB_PREFIX "" | |
77 | #define DYNLIB_EXTENSION ".dll" | |
78 | ||
79 | #else | |
80 | ||
81 | #define GDPUBLIC __attribute__((visibility("default"))) | |
82 | #define GDAPI | |
83 | #define PACK_ATTR __attribute__((packed)) | |
84 | #define likely(x) __builtin_expect((x),1) | |
85 | #define unlikely(x) __builtin_expect((x),0) | |
86 | ||
87 | #define bad_read_ptr(_p,_c) (NULL==(_p)) | |
88 | #define bad_write_ptr(_p,_c) (NULL==(_p)) | |
89 | ||
90 | #define PATH_SEPARATOR "/" | |
91 | #define PATH_SEP_CHAR '/' | |
92 | #define DYNLIB_PREFIX "lib" | |
93 | #define DYNLIB_EXTENSION ".so" | |
94 | ||
95 | #include <unistd.h> | |
96 | #include <sys/types.h> | |
97 | #include <sys/stat.h> | |
98 | #include <sys/file.h> | |
99 | #include <sys/wait.h> | |
100 | #include <fcntl.h> | |
101 | #include <pthread.h> | |
102 | #include <errno.h> | |
103 | #include <time.h> | |
104 | #include <sys/socket.h> | |
105 | #include <arpa/inet.h> | |
106 | #include <sched.h> | |
107 | #include <dlfcn.h> | |
108 | #include <signal.h> | |
109 | #include <ctype.h> | |
110 | #ifndef LINUX | |
111 | #include <android/log.h> | |
112 | #else | |
113 | #include <syslog.h> | |
114 | #endif | |
115 | ||
116 | #endif | |
117 | ||
118 | #include <stdbool.h> | |
119 | #include <stdint.h> | |
120 | ||
121 | // MobiCore stuff... | |
122 | ||
123 | #ifdef WIN32 | |
124 | #undef UUID | |
125 | #undef uuid_t | |
126 | #endif | |
127 | ||
128 | #ifdef __cplusplus | |
129 | extern "C" { | |
130 | #endif | |
131 | ||
132 | #include <MobiCoreDriverApi.h> | |
133 | #include <mcContainer.h> | |
134 | #include <tlCmApi.h> | |
135 | #include <tlCmUuid.h> | |
136 | #include <mcVersionHelper.h> | |
137 | #include <mcVersionInfo.h> | |
138 | ||
139 | enum _mcAuthState | |
140 | { | |
141 | AUTH_NONE = 0, | |
142 | AUTH_SOC, | |
143 | AUTH_ROOT, | |
144 | AUTH_SP | |
145 | }; | |
146 | ||
147 | typedef enum _mcAuthState mcAuthState; | |
148 | ||
149 | #ifdef __cplusplus | |
150 | } | |
151 | #endif | |
152 | ||
153 | #ifdef WIN32 | |
154 | #pragma pack(pop) | |
155 | #endif | |
156 | ||
157 | #include <MobiCoreRegistry.h> | |
158 | ||
159 | #define IS_VALID_SPID(_x) ((0xFFFFFFFF!=(_x)) && (0xFFFFFFFE!=(_x))) | |
160 | #define IS_VALID_ROOTID(_x) IS_VALID_SPID(_x) | |
161 | #define IS_VALID_UUID(_x) ( ((_x).value[ 0]!=0xFF) && ((_x).value[ 1]!=0xFF) &&\ | |
162 | ((_x).value[ 2]!=0xFF) && ((_x).value[ 3]!=0xFF) &&\ | |
163 | ((_x).value[ 4]!=0xFF) && ((_x).value[ 5]!=0xFF) &&\ | |
164 | ((_x).value[ 6]!=0xFF) && ((_x).value[ 7]!=0xFF) &&\ | |
165 | ((_x).value[ 8]!=0xFF) && ((_x).value[ 9]!=0xFF) &&\ | |
166 | ((_x).value[10]!=0xFF) && ((_x).value[11]!=0xFF) &&\ | |
167 | ((_x).value[12]!=0xFF) && ((_x).value[13]!=0xFF) &&\ | |
168 | ((_x).value[14]!=0xFF) && ((_x).value[15]!=0xFF) && ((_x).value[15]!=0xFE) ) | |
169 | ||
170 | #define MC_SO_PLAIN_SIZE(_struct) offsetof(_struct,co) | |
171 | #define MC_SO_ENC_SIZE(_struct) sizeof(_struct.co) | |
172 | ||
173 | #endif // _INC_MOBICORE_H_ | |
174 |