Core module implementation file. More...
#include "mcl_core/mcl_core.h"
#include "core.h"
#include "definitions.h"
#include "mcl_core/mcl_memory.h"
#include "string_util.h"
Go to the source code of this file.
Macros | |
#define | USER_AGENT_HEADER_FORMAT "MCL/" MCL_VERSION_STRING " (%s)" |
Functions | |
mcl_error_t | mcl_core_initialize (mcl_core_configuration_t *configuration, mcl_core_t **core) |
mcl_error_t | mcl_core_onboard (mcl_core_t *core) |
mcl_error_t | mcl_core_rotate_key (mcl_core_t *core) |
mcl_error_t | mcl_core_update_credentials (mcl_core_t *core) |
mcl_error_t | mcl_core_get_access_token (mcl_core_t *core) |
mcl_bool_t | mcl_core_is_onboarded (mcl_core_t *core) |
mcl_error_t | mcl_core_get_last_access_token (mcl_core_t *core, char **token) |
mcl_error_t | mcl_core_get_last_token_time (mcl_core_t *core, char **token_time) |
mcl_http_client_t * | mcl_core_get_http_client (mcl_core_t *core) |
const char * | mcl_core_get_host_name (mcl_core_t *core) |
const char * | mcl_core_get_client_id (mcl_core_t *core) |
mcl_error_t | mcl_core_destroy (mcl_core_t **core) |
Core module implementation file.
Definition in file core.c.
#define USER_AGENT_HEADER_FORMAT "MCL/" MCL_VERSION_STRING " (%s)" |
mcl_error_t mcl_core_destroy | ( | mcl_core_t ** | core | ) |
This function destroys the mcl_core_t object and frees any memory allocated.
[in] | core | Preinitialized mcl_core_t object to destroy. |
Definition at line 358 of file core.c.
References core_processor_destroy(), MCL_DEBUG, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, MCL_NULL, and MCL_OK.
Referenced by mcl_core_initialize().
mcl_error_t mcl_core_get_access_token | ( | mcl_core_t * | core | ) |
This function is used to get access token from MindSphere. The access token contains the necessary authentication credentials for further exchange requests. The agent can use this function to get a new access token when MCL_UNAUTHORIZED is returned. The agent can use mcl_core_rotate_key function to renew its secret key if mcl_core_get_access_token function returns MCL_BAD_REQUEST.
[in] | core | mcl_core_t object which is initialized and onboarded to MindSphere. |
core
is NULL. core
. Definition at line 188 of file core.c.
References core_processor_get_access_token(), MCL_ASSERT_NOT_NULL, mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FUNCTION_LEAVE_LABEL, MCL_INFO, MCL_NOT_ONBOARDED, MCL_OK, and MCL_TRUE.
const char* mcl_core_get_client_id | ( | mcl_core_t * | core | ) |
This function returns the client id.
User should not free/manipulate the client id buffer.
[in] | core | Preinitialized mcl_core_t object. |
Definition at line 342 of file core.c.
References mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_NULL, and MCL_TRUE.
const char* mcl_core_get_host_name | ( | mcl_core_t * | core | ) |
This function returns the host name.
[in] | core | Preinitialized mcl_core_t object. |
Definition at line 326 of file core.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_NULL.
mcl_http_client_t* mcl_core_get_http_client | ( | mcl_core_t * | core | ) |
This function returns the http client.
[in] | core | Preinitialized mcl_core_t object. |
Definition at line 310 of file core.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_NULL.
mcl_error_t mcl_core_get_last_access_token | ( | mcl_core_t * | core, |
char ** | token | ||
) |
This function returns a copy of last received access token.
[in] | core | Preinitialized mcl_core_t object. |
[out] | token | The lastly received access token. |
core
or token
is NULL. core
. core
does not have an access token. Definition at line 235 of file core.c.
References MCL_ASSERT_NOT_NULL, MCL_CALLOC, mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_NO_ACCESS_TOKEN_EXISTS, MCL_NOT_ONBOARDED, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_TRUE, string_util_memcpy(), and string_util_strlen().
mcl_error_t mcl_core_get_last_token_time | ( | mcl_core_t * | core, |
char ** | token_time | ||
) |
This function returns the time when last received access token is generated, NULL if server time is not received.
[in] | core | Preinitialized # mcl_core_t object. |
[out] | token_time | The epoch time when last received access token is generated. |
core
or token_time
is NULL. Definition at line 274 of file core.c.
References MCL_ASSERT_NOT_NULL, MCL_CALLOC, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_NO_SERVER_TIME, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, string_util_memcpy(), and string_util_strlen().
mcl_error_t mcl_core_initialize | ( | mcl_core_configuration_t * | configuration, |
mcl_core_t ** | core | ||
) |
This function creates and initializes an object of type mcl_core_t according to the configuration parameters passed in as an argument. Memory is allocated for the core
object and configuration parameters are copied to it.
[in] | configuration | Data structure holding the configuration parameters for the core object. |
[out] | core | Core handle which is going to be initialized. |
Definition at line 17 of file core.c.
References core_configuration_log(), core_configuration_validate(), core_processor_initialize(), MCL_ASSERT_CODE_MESSAGE, MCL_ASSERT_NOT_NULL, MCL_ASSERT_STATEMENT_CODE_MESSAGE, mcl_core_destroy(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_INFO, MCL_NEW, MCL_NULL, MCL_OK, and MCL_OUT_OF_MEMORY.
mcl_bool_t mcl_core_is_onboarded | ( | mcl_core_t * | core | ) |
This function is used to determine if core
handle is onboarded.
[in] | core | The core handle on which the onboarding check will be performed. |
core
is onboarded. Otherwise MCL_FALSE. Definition at line 220 of file core.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FALSE, MCL_NULL, and MCL_TRUE.
Referenced by mcl_core_get_access_token(), mcl_core_get_client_id(), mcl_core_get_last_access_token(), mcl_core_onboard(), mcl_core_rotate_key(), and mcl_core_update_credentials().
mcl_error_t mcl_core_onboard | ( | mcl_core_t * | core | ) |
This function registers the agent to MindSphere which is called Onboarding.
[in] | core | Preinitialized mcl_core_t object. |
core
. Definition at line 54 of file core.c.
References core_processor_register(), MCL_ALREADY_ONBOARDED, MCL_ASSERT_NOT_NULL, MCL_ASSERT_OK, mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FALSE, MCL_FUNCTION_LEAVE_LABEL, MCL_INFO, MCL_NULL, and MCL_OK.
mcl_error_t mcl_core_rotate_key | ( | mcl_core_t * | core | ) |
This function is used by the agent which is already onboarded to MindSphere to generate a new authentication key using the authentication key acquired earlier. Key rotation can be applied only when there is an authentication key available. Onboarding key is not necessary for key rotation.
[in] | core | mcl_core_t object which is initialized and onboarded to MindSphere. |
core
is NULL. core
. Definition at line 101 of file core.c.
References core_processor_register(), MCL_ASSERT_NOT_NULL, MCL_ASSERT_OK, mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FALSE, MCL_FUNCTION_LEAVE_LABEL, MCL_INFO, MCL_NOT_ONBOARDED, MCL_NULL, and MCL_OK.
mcl_error_t mcl_core_update_credentials | ( | mcl_core_t * | core | ) |
This function is used by the agent which is already onboarded to update credentials mcl_core_t handle bears typically because the credentials are changed by another process and the mcl_core_t handle has to be synchronized.
[in] | core | mcl_core_t object which is initialized and onboarded to MindSphere. |
Definition at line 149 of file core.c.
References core_processor_update_credentials(), MCL_ASSERT_NOT_NULL, MCL_ASSERT_OK, mcl_core_is_onboarded(), MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_NOT_ONBOARDED, MCL_NULL, and MCL_TRUE.