mcl_common.h
Go to the documentation of this file.
1 /*!**********************************************************************
2  *
3  * @copyright Copyright (C) 2016 Siemens Aktiengesellschaft.\n
4  * All rights reserved.
5  *
6  *************************************************************************
7  *
8  * @file mcl_common.h
9  * @date Jul 18, 2016
10  * @brief Common module interface header file.
11  *
12  * This module contains common type definitions used in various MCL modules.
13  *
14  ************************************************************************/
15 
16 #ifndef MCL_COMMON_H_
17 #define MCL_COMMON_H_
18 
19 #include "mcl/mcl_config_setup.h"
20 
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <time.h>
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #endif
29 
30  #define MCL_LOG_UTIL_LEVEL_VERBOSE 1
31  #define MCL_LOG_UTIL_LEVEL_DEBUG 2
32  #define MCL_LOG_UTIL_LEVEL_INFO 3
33  #define MCL_LOG_UTIL_LEVEL_WARN 4
34  #define MCL_LOG_UTIL_LEVEL_ERROR 5
35  #define MCL_LOG_UTIL_LEVEL_FATAL 6
36  #define MCL_LOG_UTIL_LEVEL_NONE 0xFF
37 
38  typedef size_t mcl_size_t;
39  typedef int8_t mcl_int8_t;
40  typedef int16_t mcl_int16_t;
41  typedef int32_t mcl_int32_t;
42  typedef int64_t mcl_int64_t;
43  typedef uint8_t mcl_uint8_t;
44  typedef uint16_t mcl_uint16_t;
45  typedef uint32_t mcl_uint32_t;
46  typedef uint64_t mcl_uint64_t;
47  typedef mcl_uint8_t mcl_bool_t;
48  typedef time_t mcl_time_t;
49 
53  #define MCL_FALSE ((mcl_bool_t)0)
54  #define MCL_TRUE ((mcl_bool_t)1)
55 
59  #define MCL_MAXIMUM_HTTP_PAYLOAD_SIZE (10485760)
60 
64  typedef enum E_MCL_PROXY
65  {
73  } E_MCL_PROXY;
74 
79  {
83 
88  {
100 
104  typedef enum E_MCL_SOURCE_TYPE
105  {
110 
114  typedef enum E_MCL_EVENT_SEVERITY
115  {
121 
125  typedef enum E_MCL_EVENT_OPTION
126  {
131 
137  typedef enum E_MCL_ERROR_CODE
138  {
139  // General error codes.
140  MCL_OK = 0,
156 
157  // Error codes for configuration parameters.
170 
171  // HTTPS error codes.
193 
194  // Status error codes.
202 
203  // Operational error codes.
214 
215  // Internal error codes.
222  //Do NOT add new error codes after MCL_ERROR_CODE_END!!!
224 
239  typedef E_MCL_ERROR_CODE (*mcl_load_shared_secret_callback_t)(char **client_id, char **client_secret, char **registration_access_token, char **registration_uri);
240 
255  typedef E_MCL_ERROR_CODE (*mcl_save_shared_secret_callback_t)(const char *client_id, const char *client_secret, const char *registration_access_token,
256  const char *registration_uri);
257 
272  typedef E_MCL_ERROR_CODE (*mcl_load_rsa_callback_t)(char **client_id, char **public_key, char **private_key, char **registration_access_token, char **registration_uri);
273 
288  typedef E_MCL_ERROR_CODE (*mcl_save_rsa_callback_t)(const char *client_id, const char *public_key, const char *private_key, const char *registration_access_token,
289  const char *registration_uri);
290 
295  {
299 
304  {
308 
320 
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif //MCL_COMMON_H_
Mindsphere hostname is used for connection as configuration type.
Definition: mcl_common.h:89
Proxy type is used for connection as configuration type.
Definition: mcl_common.h:94
Source type is asset.
Definition: mcl_common.h:106
The system does not support file handling.
Definition: mcl_common.h:145
E_MCL_SOURCE_TYPE
Source type values for mcl entities.
Definition: mcl_common.h:104
mcl_load_rsa_callback_t rsa
Callback type to load RSA key.
Definition: mcl_common.h:297
Agent is not onboarded to the server yet and does not possess an authentication key.
Definition: mcl_common.h:196
Source type is application.
Definition: mcl_common.h:107
E_MCL_ERROR_CODE(* mcl_save_shared_secret_callback_t)(const char *client_id, const char *client_secret, const char *registration_access_token, const char *registration_uri)
Callback function prototype to save registration information for Shared Secret security profile...
Definition: mcl_common.h:255
uint64_t mcl_uint64_t
Definition: mcl_common.h:46
Internal failure in MCL.
Definition: mcl_common.h:141
int64_t mcl_int64_t
Definition: mcl_common.h:42
SOCKS5 proxy.
Definition: mcl_common.h:70
E_MCL_PROXY
Proxy type definitions. Used inside of mcl_configuration_t.
Definition: mcl_common.h:64
Source type is agent.
Definition: mcl_common.h:108
E_MCL_SECURITY_PROFILE
Definitions of different security profiles for onboarding.
Definition: mcl_common.h:78
The server certificate provided is in improper format and it can not be parsed.
Definition: mcl_common.h:179
Severity level of event is WARNING.
Definition: mcl_common.h:117
SOCKS4a proxy.
Definition: mcl_common.h:71
MindSphere proxy password given as a configuration parameter is either NULL or of inappropriate size...
Definition: mcl_common.h:162
If a particular operation is not supported.
Definition: mcl_common.h:148
A problem occured when sending data to the network.
Definition: mcl_common.h:176
If provided index is greater than collection size.
Definition: mcl_common.h:151
Server proof received with the server nonce mismatch.
Definition: mcl_common.h:210
Severity level of event is ERROR.
Definition: mcl_common.h:116
Unknown proxy.
Definition: mcl_common.h:66
If the response of server is HTTP 403.
Definition: mcl_common.h:186
Given log level is invalid.
Definition: mcl_common.h:147
Domain is used for connection as configuration type.
Definition: mcl_common.h:97
Host name given as a configuration parameter is either NULL or of inappropriate size.
Definition: mcl_common.h:158
E_MCL_EVENT_OPTION
Optional parameters for event.
Definition: mcl_common.h:125
Http 1.0 proxy.
Definition: mcl_common.h:68
MCL failed to connect to the host or proxy.
Definition: mcl_common.h:174
Description option.
Definition: mcl_common.h:128
Occurs when same item is tried to be added to a collection of unique items.
Definition: mcl_common.h:152
Event severity level is invalid.
Definition: mcl_common.h:153
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
Definition: mcl_common.h:137
time_t mcl_time_t
Definition: mcl_common.h:48
E_MCL_CONFIGURATION_TYPE
Configuration types used in connection to the mindsphere.
Definition: mcl_common.h:87
Proxy user name is used for connection as configuration type.
Definition: mcl_common.h:95
End of error codes.
Definition: mcl_common.h:221
Part of the data in store is written to the http request. There is still data left needs to be writte...
Definition: mcl_common.h:219
Max HTTP payload size for every HTTP request given as configuration parameter is inappropriate size...
Definition: mcl_common.h:167
Proxy port is used for connection as configuration type.
Definition: mcl_common.h:93
Configuration setup module interface header file.
Severity level of event is INFORMATION.
Definition: mcl_common.h:118
Security profile given as a configuration parameter is invalid. Please check the security profile opt...
Definition: mcl_common.h:164
The store trying to be exchanged has no data inside.
Definition: mcl_common.h:198
Tenant for JWT is NULL.
Definition: mcl_common.h:166
uint32_t mcl_uint32_t
Definition: mcl_common.h:45
mcl_save_shared_secret_callback_t shared_secret
Callback type to save shared secret.
Definition: mcl_common.h:305
Neither initial access token - initial registration URI pair nor the store path with registration inf...
Definition: mcl_common.h:168
No access token exists in mcl_communication_t handle.
Definition: mcl_common.h:155
Http proxy.
Definition: mcl_common.h:67
uint16_t mcl_uint16_t
Definition: mcl_common.h:44
E_MCL_ERROR_CODE(* mcl_load_shared_secret_callback_t)(char **client_id, char **client_secret, char **registration_access_token, char **registration_uri)
Callback function prototype to load registration information for Shared Secret security profile...
Definition: mcl_common.h:239
If given content for Base64 encoding is bad.
Definition: mcl_common.h:207
void(* mcl_leave_critical_section_callback_t)(void)
Callback function prototype to leave critical section (onboarding, key rotation, updating security in...
Definition: mcl_common.h:326
There is no more space left in http message buffer. No data has been written in current call...
Definition: mcl_common.h:216
If the response of server is unexpected.
Definition: mcl_common.h:192
General invalid parameter fail.
Definition: mcl_common.h:144
uint8_t mcl_uint8_t
Definition: mcl_common.h:43
There is no element in the array.
Definition: mcl_common.h:218
If agent cannot enter critical section.
Definition: mcl_common.h:201
E_MCL_ERROR_CODE(* mcl_save_rsa_callback_t)(const char *client_id, const char *public_key, const char *private_key, const char *registration_access_token, const char *registration_uri)
Callback function prototype to save registration information for RSA security profile.
Definition: mcl_common.h:288
E_MCL_ERROR_CODE(* mcl_load_rsa_callback_t)(char **client_id, char **public_key, char **private_key, char **registration_access_token, char **registration_uri)
Callback function prototype to load registration information for RSA security profile.
Definition: mcl_common.h:272
If the response of server is HTTP 206.
Definition: mcl_common.h:183
mcl_load_shared_secret_callback_t shared_secret
Callback type to load shared secret.
Definition: mcl_common.h:296
Correlation id option.
Definition: mcl_common.h:127
Unexpected endpoint type is received by the function to create a URI.
Definition: mcl_common.h:206
SOCKS4 proxy.
Definition: mcl_common.h:69
Security profile is used for connection as configuration type.
Definition: mcl_common.h:98
User-Agent for every HTTP request given as configuration parameter is either NULL or longer than 32 c...
Definition: mcl_common.h:165
int16_t mcl_int16_t
Definition: mcl_common.h:40
Adding final closing boundary and Authentication header is failed.
Definition: mcl_common.h:220
If the response of server is HTTP 413.
Definition: mcl_common.h:190
Proxy host name given as a configuration parameter could not be resolved.
Definition: mcl_common.h:172
Mindsphere certificate was not verified.
Definition: mcl_common.h:178
MindSphere proxy user name given as a configuration parameter is either NULL or of inappropriate size...
Definition: mcl_common.h:161
If the response of server is HTTP 400.
Definition: mcl_common.h:184
Initialization of MCL fails.
Definition: mcl_common.h:204
Proxy hostname is used for connection as configuration type.
Definition: mcl_common.h:92
If the response of server is HTTP 409.
Definition: mcl_common.h:188
MindSphere proxy domain given as a configuration parameter is either NULL or of inappropriate size...
Definition: mcl_common.h:163
If the response of server is HTTP 404.
Definition: mcl_common.h:187
MindSphere certificate given as a configuration parameter is either NULL or of inappropriate size...
Definition: mcl_common.h:159
File can not be opened.
Definition: mcl_common.h:149
The system does not have a storage medium.
Definition: mcl_common.h:146
If the response of server is HTTP 201.
Definition: mcl_common.h:182
size_t mcl_size_t
Definition: mcl_common.h:38
No more space is left to add an additional object.
Definition: mcl_common.h:217
mcl_uint8_t mcl_bool_t
Definition: mcl_common.h:47
Json child which we try to get doesn&#39;t exist in the parent Json object.
Definition: mcl_common.h:208
Success.
Definition: mcl_common.h:140
SOCKS5 hostname proxy.
Definition: mcl_common.h:72
Registration information is not loaded.
Definition: mcl_common.h:212
File provided in store path parameter in configuration structure is not accessible.
Definition: mcl_common.h:169
Host name given as a configuration parameter could not be resolved.
Definition: mcl_common.h:173
MCL is not initialized, mcl_communication_initialize() function must be called first.
Definition: mcl_common.h:195
Midsphere certificate is used for connection as configuration type.
Definition: mcl_common.h:91
A problem occured during SSL/TLS handshake.
Definition: mcl_common.h:175
The same name can not be added in the same level of json object.
Definition: mcl_common.h:150
Registration information is not saved.
Definition: mcl_common.h:211
Mindsphere port is used for connection as configuration type.
Definition: mcl_common.h:90
The server did not respond within a timeout period.
Definition: mcl_common.h:180
The streaming is active and shouldn&#39;t be interrupted.
Definition: mcl_common.h:199
Agent is already onboarded to the server, hence the library did not try to onboard again...
Definition: mcl_common.h:197
Server time is not received from the server.
Definition: mcl_common.h:154
Store which is not streamable has an item that does not fit in a single http request.
Definition: mcl_common.h:205
Memory allocation fail.
Definition: mcl_common.h:143
E_MCL_EVENT_SEVERITY
Severity values for events.
Definition: mcl_common.h:114
A problem occured when receiving data from the network.
Definition: mcl_common.h:177
Password is used for connection as configuration type.
Definition: mcl_common.h:96
int8_t mcl_int8_t
Definition: mcl_common.h:39
Security information of the mcl_communication is already up to date.
Definition: mcl_common.h:200
MindSphere proxy host name given as a configuration parameter is either NULL or of inappropriate size...
Definition: mcl_common.h:160
If the response of server is HTTP 429.
Definition: mcl_common.h:191
Internal server error.
Definition: mcl_common.h:181
E_MCL_ERROR_CODE(* mcl_enter_critical_section_callback_t)(void)
Callback function prototype to enter critical section (onboarding, key rotation, updating security in...
Definition: mcl_common.h:319
int32_t mcl_int32_t
Definition: mcl_common.h:41
Indicates that a provided buffer does not have enough size for the operation.
Definition: mcl_common.h:213
If SHA256 calculation fails.
Definition: mcl_common.h:209
Details option.
Definition: mcl_common.h:129
If the response of server is HTTP 401.
Definition: mcl_common.h:185
Received parameter is null.
Definition: mcl_common.h:142
mcl_save_rsa_callback_t rsa
Callback type to save RSA key.
Definition: mcl_common.h:306
If the response of server is HTTP 412.
Definition: mcl_common.h:189