38 #define SERVER_NONCE "server_nonce" 39 #define SERVER_PROOF "server_proof" 41 #define JSON_NAME_CLIENT_ID "client_id" 42 #define JSON_NAME_TOKEN_ENDPOINT_AUTH_METHOD "token_endpoint_auth_method" 43 #define JSON_NAME_GRANT_TYPES "grant_types" 44 #define JSON_NAME_CLIENT_SECRET "client_secret" 45 #define JSON_NAME_CLIENT_SECRET_EXPIRES_AT "client_secret_expires_at" 46 #define JSON_NAME_REGISTRATION_ACCESS_TOKEN "registration_access_token" 47 #define JSON_NAME_REGISTRATION_CLIENT_URI "registration_client_uri" 48 #define JSON_NAME_JWKS "jwks" 49 #define JSON_NAME_KEYS "keys" 50 #define JSON_NAME_E "e" 51 #define JSON_NAME_N "n" 52 #define JSON_NAME_KTY "kty" 53 #define JSON_NAME_KID "kid" 54 #define JSON_NAME_ACCESS_TOKEN "access_token" 56 #define REGISTER_URI_PATH "/register" 57 #define ACCESS_TOKEN_URI_PATH "/token" 60 #define MAX_STREAM_CALLBACK_CALL_COUNT 10 62 #define MAX_RANGE_HEADER_LENGTH (100) 63 #define MAX_TOP_EVENT_PARAMETER_LENGTH (50) 64 #define EVENT_REQUEST_LIMIT (100) 66 #define CORRELATION_ID_BYTE_LENGTH 16 112 #if MCL_FILE_DOWNLOAD_ENABLED 168 #if MCL_STREAM_ENABLED 198 DEBUG_ENTRY(
"configuration_t *configuration = <%p>, http_processor_t **http_processor = <%p>", configuration, http_processor)
215 (*http_processor)->http_client =
MCL_NULL;
216 (*http_processor)->security_handler =
MCL_NULL;
219 (*http_processor)->configuration = configuration;
224 MCL_DEBUG(
"Http client is successfully initialized.");
229 MCL_DEBUG(
"Security handler is successfully initialized.");
233 if ((
MCL_NULL != (*http_processor)->configuration->load_function.rsa &&
MCL_NULL != (*http_processor)->configuration->save_function.rsa) ||
MCL_NULL != (*http_processor)->configuration->store_path)
236 if(
MCL_NULL != (*http_processor)->configuration->load_function.rsa &&
MCL_NULL != (*http_processor)->configuration->save_function.rsa)
247 return_code =
storage_load_shared_secret_registration_information((*http_processor)->configuration->store_path, &((*http_processor)->security_handler->client_id), &((*http_processor)->security_handler->client_secret), &((*http_processor)->security_handler->registration_access_token), &((*http_processor)->security_handler->registration_client_uri));
251 return_code =
storage_load_rsa_registration_information((*http_processor)->configuration->store_path, &((*http_processor)->security_handler->client_id), &((*http_processor)->security_handler->rsa.public_key), &((*http_processor)->security_handler->rsa.private_key), &((*http_processor)->security_handler->registration_access_token), &((*http_processor)->security_handler->registration_client_uri));
260 if (
MCL_OK == return_code)
262 MCL_INFO(
"MCL is initialized with registration information provided in registration information file.");
266 if ((
MCL_NULL == (*http_processor)->configuration->initial_access_token))
268 MCL_ERROR(
"No registration information is provided.");
281 MCL_INFO(
"MCL is initialized to onboard with initial registration information.");
293 if ((
MCL_NULL == (*http_processor)->configuration->initial_access_token))
295 MCL_ERROR(
"No registration information is provided.");
308 MCL_INFO(
"MCL is initialized to onboard with initial registration information.");
325 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
413 MCL_ERROR(
"HTTP request can not be sent to the server.");
421 MCL_ERROR(
"Onboarding failed: Correlation-ID = \"%s\"", correlation_id->
buffer);
424 && (
MCL_OK != (result = server_response)))
426 MCL_ERROR(
"Key rotation failed: Correlation-ID = \"%s\"", correlation_id->
buffer);
461 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
467 char *registration_access_token =
MCL_NULL;
485 if(callbacks_are_used)
493 code = http_processor->
configuration->
load_function.
rsa(&client_id, &public_key, &private_key, ®istration_access_token, ®istration_uri);
501 client_secret = client_secret_string->
buffer;
507 client_id = client_id_string->
buffer;
508 registration_access_token = registration_access_token_string->
buffer;
544 if(
MCL_OK == code && callbacks_are_used)
582 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
622 if (
MCL_OK == optional_field_code)
635 MCL_ERROR(
"Getting access token failed. Correlation-ID = \"%s\"", correlation_id->
buffer);
656 #if MCL_FILE_DOWNLOAD_ENABLED 659 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, mcl_uint8_t *buffer = <%p>, mcl_size_t start_byte = <%u>, mcl_size_t end_byte <%u>, string_t *file_id = <%p>, mcl_bool_t with_range = <%d>, file_t **file = <%p>",
660 http_processor, buffer, start_byte, end_byte, file_id, with_range, file)
685 (
MCL_OK == result) && (
MCL_TRUE == with_range) && (result = _add_range_header(request, start_byte, end_byte));
707 MCL_ERROR(
"Acknowledge events failed. Correlation-ID = \"%s\"", correlation_id->
buffer);
727 if (
MCL_NULL != content_disposition_header)
729 result = _get_file_name(content_disposition_header->
buffer, &(*file)->meta.payload.details.file_details.file_name);
746 (*file)->payload.buffer = buffer;
768 DEBUG_ENTRY(
"string_t *host = <%p>, string_t *endpoint = <%p>, string_t **uri = <%p>", host, endpoint, uri)
788 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, store_t *store = <%p>, void **reserved = <%p>", http_processor, store, reserved)
808 MCL_DEBUG(
"Start of a fill and send iteration");
823 MCL_DEBUG(
"A new http_request has been initialized");
849 MCL_DEBUG(
"Evaluating the result returned as failed. Terminating the exchange operation.");
857 MCL_DEBUG(
"An error has been occured during http request preparation = <%d>. Terminating the exchange operation.", result);
872 #if MCL_STREAM_ENABLED 873 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, store_t *store = <%p>, void **reserved = <%p>", http_processor, store, reserved)
892 send_callback_info.
user_context = &http_processor_callback_context;
905 http_processor_callback_context.
request = request;
909 if (MCL_OK != result)
927 if (MCL_OK != result)
929 MCL_DEBUG(
"Evaluating the result returned as failed. Terminating the exchange operation.");
938 (void)http_processor;
943 #endif // MCL_STREAM_ENABLED 948 DEBUG_ENTRY(
"http_processor_t **http_processor = <%p>", http_processor)
959 string_destroy(&((*http_processor)->configuration->access_token_endpoint));
960 string_destroy(&((*http_processor)->configuration->exchange_endpoint));
961 string_destroy(&((*http_processor)->configuration->registration_endpoint));
966 MCL_DEBUG(
"Http processor handle is destroyed.");
970 MCL_DEBUG(
"Http processor handle is already NULL.");
978 DEBUG_ENTRY(
"store_data_t *current_store_data = <%p>, http_request_t *request = <%p>", current_store_data, request)
1011 "Get content type and id info failed!");
1038 if (0 < left_meta_size)
1043 if (0 < available_size_in_request)
1046 if (left_meta_size > available_size_in_request)
1048 MCL_DEBUG(
"Left meta size has been reduced to available size in request = <%u>", available_size_in_request);
1049 left_meta_size = available_size_in_request;
1062 MCL_DEBUG(
"Available space in request is 0.");
1069 if (0 == left_meta_size)
1086 if (0 < available_size_in_request)
1089 if (left_payload_size > available_size_in_request)
1091 MCL_DEBUG(
"Left payload size has been equalized to available size in request = <%u>", available_size_in_request);
1092 left_payload_size = available_size_in_request;
1100 MCL_DEBUG(
"Type is STORE_DATA_FILE. Calling file read callback function.");
1109 MCL_DEBUG(
"Type is STORE_DATA_STREAM. Calling user provided read callback function = <%p>, with user_context = <%p>", stream_data->
read_callback,
1114 available_size_in_request, &actual_written);
1116 if ((
MCL_OK == result) && (0 == actual_written))
1118 MCL_DEBUG(
"User callback completed writing data.");
1127 MCL_DEBUG(
"Type is <standard types>. Calling memory read callback function.");
1140 MCL_DEBUG(
"Available space in request is 0.");
1148 if ((0 == left_meta_size) && (0 == left_payload_size))
1153 MCL_DEBUG(
"Meta and payload have been written completely. Updating its state to WRITTEN.");
1163 DEBUG_ENTRY(
"store_data_t *current_store_data = <%p>, http_request_t *request = <%p>", current_store_data, request)
1174 MCL_DEBUG(
"This is a streaming data. We don't know the size. Returning MCL_HTTP_REQUEST_NO_MORE_SPACE to make it be written with stream method.");
1184 "Get content type and id info failed!");
1191 current_store_data->
payload_size, payload_content_type);
1196 current_store_data->
payload_size, payload_content_type);
1208 MCL_DEBUG(
"No more space left in the request for normal writing the data.");
1214 MCL_DEBUG(
"Error response received from http_request_add_tuple");
1224 DEBUG_ENTRY(
"store_data_t *store_data = <%p>", store_data)
1312 "Get meta string from item meta for custom_data has been failed!");
1321 MCL_DEBUG(
"Item type = <data_source_configuration>");
1348 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, store_t *store = <%p>, http_request_t *request = <%p>", http_processor, store, request)
1419 MCL_DEBUG(
"Current data has been added to the http request successfully. We continue to add for other items in the list.");
1425 MCL_DEBUG(
"There is not enough space left in the http request for current data.");
1432 MCL_DEBUG(
"Streaming is already active for current data. Returning right away to write the rest.");
1439 MCL_DEBUG(
"Streaming is enabled. Streaming will be tried for this one.");
1452 MCL_DEBUG(
"Error response received from http request add operation. Aborting the operation!");
1458 MCL_DEBUG(
"Current data in the store is not in PREPARED state. Either it is not ready or it is already written. Skipping..");
1465 current_list_node = current_list_node->
next;
1469 MCL_DEBUG(
"Since streaming is active for current data, not iterating to the next store data.");
1474 MCL_DEBUG(
"End of list reached in the list.");
1482 MCL_DEBUG(
"No item has been added to the request in this iteration. There is no suitable data in the store for the current request. Not going to try again.");
1487 MCL_DEBUG(
"Some data has been added to the list in this iteration. We will try again from the beginning of the list. We might fit some more data.");
1493 current_list_node = current_list->
head;
1503 MCL_DEBUG(
"Not any of the data in the store could be added to the request. There is no suitable data in it.");
1508 MCL_DEBUG(
"Http request is ready to send. Finalizing..");
1518 DEBUG_ENTRY(
"store_t *store = <%p>, E_MCL_ERROR_CODE send_result = <%d>, http_response_t *response = <%p>, void **reserved = <%p>, string_t *correlation_id = <%p>", store, send_result, response, reserved, correlation_id)
1525 if (
MCL_OK == send_result)
1531 MCL_INFO(
"Send operation is successful. 200 OK Has been received from server. Correlation-ID = \"%s\"", correlation_id->
buffer);
1537 MCL_ERROR(
"Send operation is successful. ERROR code has been received from server = <%d>. Correlation-ID = \"%s\"", response->
result_code, correlation_id->
buffer);
1547 MCL_DEBUG(
"HTTP response object is NULL. Means the send operation is failed!");
1552 MCL_DEBUG(
"Send result is not successful.");
1553 result = send_result;
1573 DEBUG_ENTRY(
"store_data_t *store_data = <%p>, mcl_bool_t send_operation_successful = <%u>", store_data, send_operation_successful)
1579 if (
MCL_TRUE == send_operation_successful)
1593 MCL_DEBUG(
"State is %d, no need to update current items state", state);
1602 DEBUG_ENTRY(
"store_t *store = <%p>, mcl_bool_t send_operation_successful = <%u>", store, send_operation_successful)
1657 DEBUG_ENTRY(
"store_data_t *store_data = <%p>, string_t *meta_content_type = <%p>, string_t *meta_content_id = <%p>, string_t *payload_content_type = <%p>", store_data,
1658 meta_content_type, meta_content_id, payload_content_type)
1721 MCL_DEBUG(
"Item type = <data_source_configuration>");
1744 DEBUG_ENTRY(
"http_request_t *request = <%p>", request)
1765 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, http_request_t *request = <%p>", http_processor, request)
1779 if (
MCL_TRUE == with_authentication)
1801 DEBUG_ENTRY(
"void *destination = <%p>, void *source = <%p>, mcl_size_t size = <%u>, void *user_context = <%p>", destination, source, size, user_context)
1814 DEBUG_ENTRY(
"void *destination = <%p>, void *file_descriptor = <%p>, mcl_size_t size = <%u>, void *user_context = <%p>", destination, file_descriptor, size, user_context)
1821 file_util_fread(destination, 1, size, file_descriptor, &actual_size_read);
1824 return actual_size_read;
1827 #if MCL_STREAM_ENABLED 1830 DEBUG_ENTRY(
"void *buffer = <%p>, mcl_size_t size = <%u>, mcl_size_t count = <%u>, void *user_context = <%p>", buffer, size, count, user_context)
1836 store_t *store = http_processor_callback_context->
store;
1859 MCL_DEBUG(
"Second try of http_request_finalize is failed again! Terminating the operation.");
1882 MCL_DEBUG(
"Fill http request operation is failed. Terminating send operation.");
1889 MCL_DEBUG(
"Fill operation result will be saved to be used in next call = <%u>.", result);
1899 MCL_DEBUG(
"Max callback call limit has been reached. Call count = <%d>. Terminating the send operation.", http_processor_callback_context->
call_count);
1903 http_processor_callback_context->
call_count++;
1912 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, http_response_t *http_response = <%p>", http_processor, http_response)
1953 MCL_FREE(registration_access_token);
1963 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>, http_response_t *http_response = <%p>", http_processor, http_response)
1998 MCL_FREE(registration_access_token);
2006 #if MCL_FILE_DOWNLOAD_ENABLED 2009 DEBUG_ENTRY(
"char *header = <%p>, char **file_name = <%p>", header, file_name)
2019 char *file_name_keyword =
"filename";
2027 file_name_index += file_name_keyword_length;
2034 first_quote_index += file_name_index;
2040 mcl_size_t file_name_size = (second_quote_index + 1);
2041 char *file_name_local =
MCL_MALLOC(file_name_size + 1);
2055 #if MCL_FILE_DOWNLOAD_ENABLED 2058 DEBUG_ENTRY(
"http_request_t *request = <%p>, mcl_size_t start_byte = <%u>, mcl_size_t end_byte = <%u>", request, start_byte, end_byte)
2063 ASSERT_CODE_MESSAGE(
MCL_OK == result, result,
"string_util_snprintf() failed for start_byte <%u> and end_byte <%u>", start_byte, end_byte);
2079 DEBUG_ENTRY(
"http_response_t *response = <%p>, mcl_file_t *file = <%p>", response, file)
2089 char *
string = content_range_header->
buffer;
2092 while (!((47 < *
string) && (58 > *
string)))
2105 while (!((47 < *rest) && (58 > *rest)))
2127 DEBUG_ENTRY(
"security_handler_t *security_handler = <%p>, string_t **payload = <%p>", security_handler, payload)
2169 DEBUG_ENTRY(
"security_handler_t *security_handler = <%p>, string_t **payload = <%p>", security_handler, payload)
2216 DEBUG_ENTRY(
"json_t *root = <%p>, json_t **json_object = <%p>", root, json_object)
2229 DEBUG_ENTRY(
"const char *file_name = <%p>", file_name)
2245 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
2249 char *registration_access_token;
2250 char *registration_uri;
2254 char *client_secret;
2280 DEBUG_ENTRY(
"http_response_t *response = <%p>", response)
2345 DEBUG_ENTRY(
"string_t **correlation_id = <%p>", correlation_id)
2358 code =
string_util_snprintf(&((*correlation_id)->buffer[index * 2]), 3,
"%02x", random_bytes[index]);
2368 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
2408 DEBUG_ENTRY(
"http_processor_t *http_processor = <%p>", http_processor)
2414 const char *head =
"grant_type=client_credentials&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion=";
Content type is application octet stream.
HTTP definitions module header file.
store_data_stream_info_t * stream_info
Stream information.
list_t * events
Payload of event list.
item_meta_t meta
Meta of custom data.
static E_MCL_ERROR_CODE _compose_rsa_key_rotation_json(security_handler_t *security_handler, string_t **payload)
static E_MCL_ERROR_CODE _exchange_update_store_state(store_t *store, mcl_bool_t send_operation_successful)
void string_destroy(string_t **string)
Destroys the allocated resources of the string.
http_client_t * http_client
Http client handler.
Data source configuration module header file.
Memory module header file.
long string_util_strtol(const char *source, int base, char **end_pointer)
Returns the first occurrence of an integral value in source string.
#define JSON_NAME_ACCESS_TOKEN
E_MCL_ERROR_CODE security_handler_generate_rsa_key(security_handler_t *security_handler)
To be used to generate the RSA public/private key pairs.
void http_response_destroy(http_response_t **http_response)
To destroy the HTTP Response Handler.
http_request_t * request
It is used to build http request messages.
list_t * high_priority_list
Contains high priority store_data_t data.
void file_destroy(file_t **file)
void list_reset(list_t *list)
Reset the current node to head node.
item_meta_t meta
Meta of file.
static E_MCL_ERROR_CODE _process_registration_response_shared_secret(http_processor_t *http_processor, http_response_t *http_response)
mcl_size_t(* payload_copy_callback_t)(void *destination, void *source, mcl_size_t size, void *user_context)
static E_MCL_ERROR_CODE _exchange_store_data_get_content_info(store_data_t *store_data, string_t **meta_content_type, string_t **meta_content_id, string_t **payload_content_type)
E_MCL_ERROR_CODE security_handler_initialize(security_handler_t **security_handler)
Initializer of security handler.
Type of the data in the store is time series.
E_MCL_ERROR_CODE json_util_get_string(json_t *json_item, string_t **string_value)
This function gets the string value of a given json object.
Json util module header file.
time_series_payload_t payload
Payload of time series.
E_MCL_ERROR_CODE http_response_get_header(http_response_t *http_response, char *header_name, string_t **header_value)
Get the value of a specified HTTP Header.
Type of the data in the store is stream.
static E_MCL_ERROR_CODE _concatenate_host_and_endpoint(string_t *host, string_t *endpoint, string_t **uri)
#define STRING_CONSTANT(s)
Common module interface header file.
static E_MCL_ERROR_CODE _exchange_update_store_data_state(store_data_t *store_data, mcl_bool_t send_operation_successful)
If a particular operation is not supported.
string_t * mindsphere_hostname
Mindsphere hostname.
E_MCL_ERROR_CODE string_initialize_new(const char *value, mcl_size_t value_length, string_t **string)
Initializes a new string_t object with the given value and length.
mcl_uint8_t * payload
Payload of http request.
E_MCL_ERROR_CODE http_request_start_tuple_sub_section(http_request_t *http_request, string_t *content_type, string_t *content_id, string_t **sub_boundary)
To start a sub tuple section inside of the http request body.
char * buffer
Buffer of string handle.
This struct is used for building the complete message of time series event.
configuration_t * configuration
Configuration for mcl initialization.
mcl_bool_t string_util_find(const char *source, const char *target, mcl_size_t *start_index)
Finds the first occurence of target in source and puts it's first index to start_index.
Type of the data in the store is data source configuration.
E_MCL_ERROR_CODE previous_result
Previous result of callback.
string_t * exchange_endpoint
Uri for exchange endpoint.
If the response of server is HTTP 403.
list_t * low_priority_list
Contains low priority store_data_t data.
mcl_uint8_t * buffer
Binary payload buffer.
E_MCL_ERROR_CODE json_util_start_array(json_t *root, const char *array_name, json_t **json_array)
This function creates an array in root.
#define JSON_NAME_REGISTRATION_ACCESS_TOKEN
#define HTTP_REQUEST_RESIZE_ENABLED
E_MCL_HTTP_RESULT_CODE result_code
Result code of http response.
string_t * tenant
Tenant name which is used in self issued JWT.
Initial state of a store data. Means this data is not processed before.
void string_util_strncpy(char *destination, const char *source, mcl_size_t count)
Standard library strncpy wrapper. Also sets the terminating null char at the end if source is not lon...
static E_MCL_ERROR_CODE _exchange_fill_http_request(http_processor_t *http_processor, store_t *store, http_request_t *request)
E_MCL_ERROR_CODE http_request_add_raw_data(http_request_t *http_request, payload_copy_callback_t copy_callback, void *user_context, void *data, mcl_size_t data_size, mcl_size_t *actual_written_size)
To add raw data into an http_request.
static E_MCL_ERROR_CODE _exchange_evaluate_response(store_t *store, E_MCL_ERROR_CODE send_result, http_response_t *response, void **reserved, string_t *correlation_id)
#define MCL_FALSE
MCL bool type.
E_MCL_ERROR_CODE _compose_access_token_request_payload(http_processor_t *http_processor, string_t **request_payload)
E_MCL_ERROR_CODE file_initialize(const char *version, const char *file_path, const char *file_name, const char *file_type, const char *routing, file_t **file)
E_ENDPOINT_TYPE
Enumeration for the Mindsphere endpoints.
E_MCL_ERROR_CODE string_compare_with_cstr(const string_t *string, const char *other)
Compare the contents of string_t with a C string.
E_MCL_ERROR_CODE http_processor_register(http_processor_t *http_processor)
#define MCL_MALLOC(bytes)
E_MCL_ERROR_CODE http_client_send(http_client_t *http_client, http_request_t *http_request, http_client_send_callback_info_t *callback_info, http_response_t **http_response)
Send/Receive function.
E_MCL_ERROR_CODE security_generate_random_bytes(unsigned char *buffer, mcl_size_t size)
To be used to generate random bytes.
Http Correlation-ID header name.
mcl_size_t size
Binary payload size.
E_MCL_ERROR_CODE http_request_start_tuple(http_request_t *http_request)
To start a new tuple structure inside the http request body.
Log utility module header file.
HTTP processor module header file.
E_MCL_ERROR_CODE storage_load_shared_secret_registration_information(string_t *path, string_t **client_id, string_t **client_secret, string_t **registration_access_token, string_t **registration_uri)
mcl_uint8_t call_count
Call count of stream callback.
static E_MCL_ERROR_CODE _compose_rsa_onboarding_json(security_handler_t *security_handler, string_t **payload)
E_MCL_ERROR_CODE
MCL Error code definitions. Every function returning an error code uses this enum values...
Type of the data in the store is custom data.
E_MCL_ERROR_CODE http_request_end_tuple_sub_section(http_request_t *http_request, string_t *sub_boundary)
To end a sub tuple section previously started with http_request_start_tuple_sub_section().
Content type is application/x-www-form-urlencoded.
E_MCL_ERROR_CODE file_util_fopen(const char *file_name, const char *mode, void **file_descriptor)
mcl_load_registration_information_callback_t load_function
Custom function for loading registration information; if both load_function and save_function are non...
binary_payload_t payload
Payload of custom data.
mcl_size_t payload_size
Payload size of http response.
mcl_size_t end_byte
File payload end byte.
void json_util_destroy(json_t **root)
This function destroys root.
E_MCL_ERROR_CODE string_util_snprintf(char *string, mcl_size_t length, const char *format,...)
Standard library snprintf wrapper.
Part of the data in store is written to the http request. There is still data left needs to be writte...
#define HTTP_REQUEST_RESIZE_DISABLED
Type of the data in the store is file.
mcl_size_t http_client_get_callback_termination_code()
To get the implementation specific code for returning from callback function in order to terminate th...
Content type is multipart mixed.
Streaming is active. Current data has been partially written to the current http request or about to ...
E_MCL_ERROR_CODE http_client_initialize(configuration_t *configuration, http_client_t **http_client)
HTTP Client initializer.
E_STORE_DATA_TYPE type
Type of data in the store.
The store trying to be exchanged has no data inside.
static E_MCL_ERROR_CODE _process_registration_response_rsa_3072(http_processor_t *http_processor, http_response_t *http_response)
data_source_configuration_payload_t payload
Payload of data_source_configuration.
void store_data_set_state(store_data_t *store_data, E_STORE_DATA_STATE state)
static mcl_size_t _get_payload_from_buffer(void *destination, void *source, mcl_size_t size, void *user_context)
Uri for ack event endpoint.
Neither initial access token - initial registration URI pair nor the store path with registration inf...
#define ASSERT_STATEMENT_CODE_MESSAGE(condition, statement, return_code,...)
E_MCL_HTTP_METHOD
HTTP Method Types.
#define MAX_STREAM_CALLBACK_CALL_COUNT
Type of the data in the store is event list.
struct mcl_list_node_t * next
Next node in the list.
string_t * registration_endpoint
Uri for registration endpoint.
mcl_list_node_t * head
Head node of the list.
There is no more space left in http message buffer. No data has been written in current call...
E_MCL_ERROR_CODE http_request_add_header(http_request_t *http_request, string_t *header_name, string_t *header_value)
To be used to add an HTTP header to the request with it's value.
string_t * access_token
Access token.
This struct is used for building the complete message of file.
static E_MCL_ERROR_CODE _exchange_finalize_http_request(http_processor_t *http_processor, http_request_t *request, mcl_bool_t with_authentication)
If the response of server is unexpected.
void security_handler_destroy(security_handler_t **security_handler)
To destroy the Security Handler.
mcl_save_registration_information_callback_t save_function
Custom function for saving registration information; if both load_function and save_function are non-...
E_MCL_ERROR_CODE storage_save_rsa_registration_information(string_t *path, string_t *client_id, char *public_key, char *private_key, string_t *registration_access_token, string_t *registration_uri)
static E_MCL_ERROR_CODE _add_authentication_header_to_request(http_processor_t *http_processor, http_request_t *request, mcl_bool_t with_authentication)
char * public_key
Public key.
E_ENDPOINT_URI
Enumeration for URIs for different endpoints.
item_meta_t * meta
Meta of event list.
Stream data module header file.
If the response of server is HTTP 206.
Http content range header.
#define JSON_NAME_CLIENT_ID
string_t * jwt_get_token(jwt_t *jwt)
Used to generate the JWT Token as json string.
E_MCL_ERROR_CODE security_rsa_get_modulus_and_exponent(char *public_key, char **modulus, char **exponent)
To be used to get the modulus (n) and public exponent (e) parameters of RSA key in Base64 format...
mcl_uint8_t * payload_buffer
Payload of the store.
E_MCL_ERROR_CODE json_util_get_object_item(json_t *json_parent, const char *child_name, json_t **json_child)
This function gives the value of json_child object, when the child_name in json_parent object is give...
void * descriptor
Descriptor of file.
string_t * meta
Meta of the store as json string.
Http authorization header.
void json_util_initialize_json_library()
This function initializes json library.
string_t * access_token_endpoint
Uri for access token endpoint.
void string_util_memcpy(void *destination, const void *source, mcl_size_t count)
Standard library memcpy wrapper.
string_t content_type_values[CONTENT_TYPE_VALUES_END]
string_t * client_secret
Client secret.
http_client_read_callback read_callback
#define ASSERT_STATEMENT_CODE(condition, statement, return_code)
This data has been successfully sent to the server. Can be deleted from the store.
char * private_key
Private key.
#define ASSERT_CODE_MESSAGE(condition, return_code,...)
string_t http_header_names[HTTP_HEADER_NAMES_END]
E_MCL_ERROR_CODE http_request_finalize(http_request_t *http_request)
Adds closing boundary to the payload and resizes the payload buffer to release unused memory space...
Content type is meta json.
Definitions module header file.
Storage module header file.
store_t * store
Holds references to data to exchange.
static E_MCL_ERROR_CODE _exchange_add_current_data_to_request(store_data_t *current_store_data, http_request_t *request)
Adding final closing boundary and Authentication header is failed.
Http content type header.
mcl_size_t payload_offset
Payload offset of http request.
string_t * registration_access_token
Registration access token.
static E_MCL_ERROR_CODE _custom_load_register_info(http_processor_t *http_processor)
If the response of server is HTTP 413.
File utility module header file.
#define JSON_NAME_CLIENT_SECRET
E_MCL_SECURITY_PROFILE security_profile
Security levels E_MCL_SECURITY_PROFILE.
Uri for access token endpoint.
void http_client_destroy(http_client_t **http_client)
To destroy the HTTP Client Handler.
file_payload_t payload
Payload of file.
This struct is used for building the event.
mcl_int64_t size
File payload size.
E_MCL_ERROR_CODE string_initialize_dynamic(const char *value, mcl_size_t value_length, string_t **string)
Initializes a dynamic string_t object with the given value and length.
If the response of server is HTTP 400.
E_MCL_ERROR_CODE json_from_item_meta(item_meta_t *item_meta, string_t **json_string)
Creates item meta part of all types in json format.
mcl_size_t length
Length of buffer.
mcl_stream_data_read_callback_t read_callback
Read callback of stream data.
E_MCL_ERROR_CODE json_util_add_string(json_t *root, const char *object_name, const char *object_value)
This function adds string to root which can be object or array.
If the response of server is HTTP 409.
mcl_uint8_t * http_response_get_payload(http_response_t *http_response)
Get the payload section of the HTTP Response.
void jwt_destroy(jwt_t **jwt)
To destroy the JWT Handler.
Time series module header file.
string_t * last_token_time
The time at which the last access token is received.
custom_data_t * base
Type of base is custom data.
mcl_size_t meta_stream_index
Index of meta stream.
static E_MCL_ERROR_CODE _exchange_add_current_data_to_request_by_streaming(store_data_t *current_store_data, http_request_t *request)
If the response of server is HTTP 404.
void * user_context
User context.
void file_util_fread(void *data, mcl_size_t size, mcl_size_t count, void *file_descriptor, mcl_size_t *actual_count)
E_MCL_ERROR_CODE http_processor_update_security_information(http_processor_t *http_processor)
list_node_t * list_next(list_t *list)
Get the next node from the list.
Uri for registration endpoint.
item_meta_t meta
Meta of data source configuration.
E_MCL_ERROR_CODE storage_load_rsa_registration_information(string_t *path, string_t **client_id, char **public_key, char **private_key, string_t **registration_access_token, string_t **registration_uri)
This struct is used for building the custom data type.
E_MCL_ERROR_CODE http_processor_initialize(configuration_t *configuration, http_processor_t **http_processor)
Http Processor Initialize function.
This struct is used for building the complete message of stream data.
E_STORE_DATA_STATE store_data_get_state(store_data_t *store_data)
E_MCL_ERROR_CODE string_util_strncmp(const char *string_1, const char *string_2, mcl_size_t count)
Standard library strncmp wrapper.
#define ASSERT_CODE(condition, return_code)
mcl_size_t store_get_data_count(store_t *store)
Current data has been written to the current http request as a whole.
E_MCL_ERROR_CODE file_util_fclose(void *file_descriptor)
static E_MCL_ERROR_CODE _exchange_clear_sent_data_from_store(store_t *store)
mcl_size_t payload_stream_index
Index of payload stream.
void json_util_finish_object(json_t **json_object)
This function destroys json_object data struct. But the object still exists in root json object...
E_MCL_ERROR_CODE http_processor_stream(http_processor_t *http_processor, store_t *store, void **reserved)
Exchange operation logic with streaming.
E_MCL_ERROR_CODE json_util_parse_with_size(const char *json_string, mcl_size_t size, json_t **root)
This function parses the given string to the given json object.
string_t * user_agent
User agent.
If the response of server is HTTP 201.
E_MCL_ERROR_CODE http_processor_exchange(http_processor_t *http_processor, store_t *store, void **reserved)
Exchange operation logic.
E_MCL_ERROR_CODE json_from_time_series_payload(time_series_payload_t *payload, string_t **json_string)
Creates payload part of time series in json format.
HTTP request module header file.
void http_request_destroy(http_request_t **http_request)
To destroy the HTTP Request Handler.
E_MCL_ERROR_CODE storage_save_shared_secret_registration_information(string_t *path, string_t *client_id, string_t *client_secret, string_t *registration_access_token, string_t *registration_uri)
mcl_bool_t streamable
Defines if the data in store is streamable or not.
mcl_size_t max_http_payload_size
Not valid for streamable request. Default value is 16K Bytes. Minimum value is 400 Bytes and maximum ...
Content type is application json.
E_MCL_ERROR_CODE jwt_initialize(security_handler_t *security_handler, E_MCL_SECURITY_PROFILE security_profile, string_t *tenant, jwt_t **jwt)
JWT Initializer.
string_t endpoint_uri[ENDPOINT_URI_END]
Registration information is not loaded.
File provided in store path parameter in configuration structure is not accessible.
Handle struct for security_handler module.
Custom data module header file.
static E_MCL_ERROR_CODE _exchange_initialize_http_request_headers(http_processor_t *http_processor, http_request_t *request, mcl_bool_t with_authentication)
security_handler_t * security_handler
Security handler.
int payload_state
Payload state.
mcl_list_node_t * current
Current node of the list.
#define CORRELATION_ID_BYTE_LENGTH
void security_initialize(void)
mcl_size_t start_byte
File payload start byte.
#define JSON_NAME_REGISTRATION_CLIENT_URI
E_MCL_ERROR_CODE string_initialize_static(const char *value, mcl_size_t value_length, string_t **string)
Initializes a static string_t object with the given value and length.
Security module header file.Inner security interface. Contains security related functions like hashin...
item_meta_t meta
Meta of time series.
static mcl_size_t _get_payload_from_file(void *destination, void *file_descriptor, mcl_size_t size, void *user_context)
E_MCL_ERROR_CODE json_util_to_string(json_t *root, char **json_string)
This function gives the string of root in json format.
static E_MCL_ERROR_CODE _exchange_prepare_data(store_data_t *store_data)
E_MCL_ERROR_CODE http_processor_get_access_token(http_processor_t *http_processor)
void * data
Data to be added to the store.
mcl_size_t count
Node count of the list.
int meta_state
Meta state.
The streaming is active and shouldn't be interrupted.
string_t * registration_client_uri
Registration client uri.
http_processor_t * http_processor
Http processer handle.
Random module header file.
E_MCL_ERROR_CODE json_from_data_source_configuration_payload(data_source_configuration_payload_t *payload, string_t **json_string)
Creates payload part of data source configuration in json format.
Store which is not streamable has an item that does not fit in a single http request.
string_t * initial_access_token
Initial access token. Not used by the library if a registration access token is present in store_path...
Event list module header file.
string_t * tuple_subboundary
Subboundary of tuple.
Prepared. Means its meta and payload strings has been prepared.
Http content disposition header.
string_t * store_path
Path of the file the library uses to save registration artifacts such as registration access token...
void json_util_add_item_to_array(json_t *root, json_t *object)
This function adds object to root array.
mcl_size_t http_request_get_available_space_for_raw_data(http_request_t *http_request)
To be used to get the available space left in the request buffer in order to add a raw data...
Security information of the mcl_communication is already up to date.
string_t * client_id
Client id.
Uri for download endpoint.
E_MCL_ERROR_CODE http_request_initialize(E_MCL_HTTP_METHOD method, string_t *uri, mcl_size_t header_size, mcl_size_t payload_size, mcl_bool_t resize_enabled, string_t *user_agent, mcl_size_t max_http_payload_size, http_request_t **http_request)
HTTP Request Initializer.
static E_MCL_ERROR_CODE _add_key_to_keys_array(json_t *root, json_t **json_object)
E_MCL_ERROR_CODE _save_registration_information(http_processor_t *http_processor)
void * data
Data of the node.
If the response of server is HTTP 429.
mcl_size_t payload_size
Payload size of http request.
E_MCL_ERROR_CODE json_from_event_payload(list_t *event_list_payload, string_t **json_string)
Creates payload part of event set in json format.
E_MCL_ERROR_CODE http_request_add_tuple(http_request_t *http_request, string_t *meta, string_t *meta_content_type, payload_copy_callback_t payload_copy_callback, void *user_context, void *payload, mcl_size_t payload_size, string_t *payload_content_type)
To be used to add a tuple to the HTTP Request.
E_MCL_ERROR_CODE json_util_start_object(json_t *root, const char *object_name, json_t **json_object)
This function creates an object in root.
E_MCL_ERROR_CODE store_data_remove(list_t *store_list, list_node_t *store_data_node)
static E_MCL_ERROR_CODE _evaluate_response_codes(http_response_t *response)
E_MCL_ERROR_CODE json_util_initialize(E_JSON_TYPE json_type, json_t **root)
This function initializes the given root json.
E_MCL_ERROR_CODE string_concatenate(string_t *string_1, string_t *string_2, string_t **result)
Concatenates a C string (i.e. a char array)
Indicates that a provided buffer does not have enough size for the operation.
Uri for exchange endpoint.
mcl_size_t string_util_strlen(const char *buffer)
Standard library strlen wrapper.
If the response of server is HTTP 401.
static E_MCL_ERROR_CODE _generate_correlation_id_string(string_t **correlation_id)
Time utility module header file.
void http_processor_destroy(http_processor_t **http_processor)
To destroy the HTTP Processor Handler.
static E_MCL_ERROR_CODE _check_file_path(const char *file_name)
mcl_size_t payload_size
Size of the payload in the store.
This struct is used for json handling.
#define MAX_RANGE_HEADER_LENGTH
If the response of server is HTTP 412.
Data types module header file.
mcl_uint8_t * payload
Payload of http response.
#define MCL_ERROR_RETURN(return_value,...)