AWS IoT Device SDK C: Fleet Provisioning
AWS IoT Fleet Provisioning
Return to main page ↑
aws_iot_provisioning_serializer.c File Reference

Implements the internal serializer functions of the Provisioning library. More...

#include "iot_config.h"
#include <string.h>
#include "iot_error.h"
#include "private/aws_iot_provisioning_internal.h"
#include "iot_logging_setup.h"

Functions

static bool _checkSuccess (IotSerializerError_t error)
 Wrapper for assert checking the passed serializer error code for IOT_SERIALIZER_SUCCESS value. More...
 
static bool _checkSuccessOrBufferToSmall (IotSerializerError_t error)
 Wrapper for assert checking the passed serializer error code for either IOT_SERIALIZER_SUCCESS or IOT_SERIALIZER_BUFFER_TOO_SMALL values. More...
 
static AwsIotProvisioningError_t _serializeCreateKeysAndCertificateRequestPayload (IotSerializerEncoderObject_t *pOutermostEncoder, uint8_t *pSerializationBuffer, size_t bufferSize)
 Performs serialization operations on the passed buffer for creating the MQTT request payload for the CreateKeysAndCertification operation. More...
 
static AwsIotProvisioningError_t _serializeCertFromCsrPayload (const char *pCertificateSigningRequest, size_t csrLength, IotSerializerEncoderObject_t *pEncoder, bool isDrySerialization)
 Common utility for serializing CreateCertificateFromCsr service API request payload used by _AwsIotProvisioning_CalculateCertFromCsrPayloadSize and _AwsIotProvisioning_SerializeCreateCertFromCsrRequestPayload functions. More...
 
static AwsIotProvisioningError_t _serializeRegisterThingRequestPayload (const AwsIotProvisioningRegisterThingRequestInfo_t *pRequestData, IotSerializerEncoderObject_t *pOutermostEncoder, uint8_t *pSerializationBuffer, size_t bufferSize)
 Performs serializes operations on the passed buffer for creating the MQTT request payload for the RegisterThing operation. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_SerializeCreateKeysAndCertificateRequestPayload (uint8_t **pSerializationBuffer, size_t *pBufferSize)
 Serializes payload data for MQTT request to the Fleet Provisioning CreateKeysAndCertificate API on AWS IoT Core. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_CalculateCertFromCsrPayloadSize (const char *pCertificateSigningRequest, size_t csrLength, size_t *pPayloadSize)
 Calculates the payload size of serializing the passed Certificate-Signing Request data for the MQTT CreateCertificateFromCsr service API. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_SerializeCreateCertFromCsrRequestPayload (const char *pCertificateSigningRequest, size_t csrLength, uint8_t *pSerializationBuffer, size_t bufferSize)
 Serializes payload data for the request to the MQTT CreateCertificateFromCsr service API, in the passed buffer. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_SerializeRegisterThingRequestPayload (const AwsIotProvisioningRegisterThingRequestInfo_t *pRequestData, uint8_t **pSerializationBuffer, size_t *pBufferSize)
 Serializes payload data for MQTT request to the Provisioning RegisterThing service API. More...
 
size_t _AwsIotProvisioning_GenerateRegisterThingTopicFilter (const char *pTemplateName, size_t templateNameLength, char *pTopicFilterBuffer)
 Utility for generating the request/response MQTT topic filter string for the ProvisioningDevice service API. More...
 

Variables

static const size_t _numKeysAndCertMapEntries = 0u
 Represents the number of map entries in the request payload of the MQTT CreateKeysAndCertificate service API.
 
static const size_t _numCertFromCsrMapEntries = 1u
 Represents the number of map entries in the request payload of the MQTT CreateCertificateFromCsr service API. The ONLY payload entry is for the Certificate-Signing Request string.
 

Detailed Description

Implements the internal serializer functions of the Provisioning library.

Function Documentation

◆ _checkSuccess()

static bool _checkSuccess ( IotSerializerError_t  error)
static

Wrapper for assert checking the passed serializer error code for IOT_SERIALIZER_SUCCESS value.

This should be used for asserting serializer status codes when performing actual serialization into a buffer.

Parameters
[in]errorThe serializer error code to assert check.

◆ _checkSuccessOrBufferToSmall()

static bool _checkSuccessOrBufferToSmall ( IotSerializerError_t  error)
static

Wrapper for assert checking the passed serializer error code for either IOT_SERIALIZER_SUCCESS or IOT_SERIALIZER_BUFFER_TOO_SMALL values.

This should be used for asserting serializer status codes when performing a serialization dry-run (i.e. serializing without a buffer) to calculate the total size of data that serialization will generate.

Parameters
[in]errorThe serializer error code to assert check.

◆ _serializeCreateKeysAndCertificateRequestPayload()

static AwsIotProvisioningError_t _serializeCreateKeysAndCertificateRequestPayload ( IotSerializerEncoderObject_t *  pOutermostEncoder,
uint8_t *  pSerializationBuffer,
size_t  bufferSize 
)
static

Performs serialization operations on the passed buffer for creating the MQTT request payload for the CreateKeysAndCertification operation.

Parameters
[in]pOutermostEncoderThe outermost encoder object to use for serialization.
[out]pSerializationBufferThe buffer to store the serialized payload data.
[in]bufferSizeThe size of the serialization buffer.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS if payload serialization is successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE.

◆ _serializeCertFromCsrPayload()

AwsIotProvisioningError_t _serializeCertFromCsrPayload ( const char *  pCertificateSigningRequest,
size_t  csrLength,
IotSerializerEncoderObject_t *  pEncoder,
bool  isDrySerialization 
)
static

Common utility for serializing CreateCertificateFromCsr service API request payload used by _AwsIotProvisioning_CalculateCertFromCsrPayloadSize and _AwsIotProvisioning_SerializeCreateCertFromCsrRequestPayload functions.

Parameters
[in]pCertificateSigningRequestThe Certificate-Signing Request string to serialize for the request.
[in]csrLengthThe length of the Certificate-Signing Request string.
[in]pEncoderThe encoder object representing the buffer to serialize the payload in.
[in]isDrySerializationA dry-run serialization flag to represent whether the serialization operation will occur without a buffer.
Returns
AWS_IOT_PROVISIONING_SUCCESS if serialization successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE to represent serialization failures.

◆ _serializeRegisterThingRequestPayload()

static AwsIotProvisioningError_t _serializeRegisterThingRequestPayload ( const AwsIotProvisioningRegisterThingRequestInfo_t pRequestData,
IotSerializerEncoderObject_t *  pOutermostEncoder,
uint8_t *  pSerializationBuffer,
size_t  bufferSize 
)
static

Performs serializes operations on the passed buffer for creating the MQTT request payload for the RegisterThing operation.

Parameters
[in]pRequestDataThe data that will be serialized for sending with the request.
[in]pOutermostEncoderThe outermost encoder object to use for serialization.
[out]pSerializationBufferThe buffer to store the serialized payload data.
[in]bufferSizeThe size of the serialization buffer.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS if payload serialization is successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE.

◆ _AwsIotProvisioning_SerializeCreateKeysAndCertificateRequestPayload()

AwsIotProvisioningError_t _AwsIotProvisioning_SerializeCreateKeysAndCertificateRequestPayload ( uint8_t **  pSerializationBuffer,
size_t *  pBufferSize 
)

Serializes payload data for MQTT request to the Fleet Provisioning CreateKeysAndCertificate API on AWS IoT Core.

Parameters
[out]pSerializationBufferThis will be assigned to a buffer that will be allocated and populated with the serialized payload data.
[out]pBufferSizeThis will be populated with the size of the allocated payload data buffer.
Returns
AWS_IOT_PROVISIONING_SUCCESS if serialization is successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE for any serialization error.

◆ _AwsIotProvisioning_CalculateCertFromCsrPayloadSize()

AwsIotProvisioningError_t _AwsIotProvisioning_CalculateCertFromCsrPayloadSize ( const char *  pCertificateSigningRequest,
size_t  csrLength,
size_t *  pPayloadSize 
)

Calculates the payload size of serializing the passed Certificate-Signing Request data for the MQTT CreateCertificateFromCsr service API.

Note
This function performs a dry-run serialization of the payload data to calculate the payload size. This function should be called to determine the size of the buffer to allocate for the actual payload serialization.
Parameters
[in]pCertificateSigningRequestThe Certificate-Signing Request string which represents the data to be serialized in the payload.
[in]csrLengthThe length of the Certificate-Signing Request string.
[in]pPayloadSizeThis will be populated with the size of the serialized data.
Returns
AWS_IOT_PROVISIONING_SUCCESS if calculation of the payload size is successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE for any serialization failures.

◆ _AwsIotProvisioning_SerializeCreateCertFromCsrRequestPayload()

AwsIotProvisioningError_t _AwsIotProvisioning_SerializeCreateCertFromCsrRequestPayload ( const char *  pCertificateSigningRequest,
size_t  csrLength,
uint8_t *  pSerializationBuffer,
size_t  pBufferSize 
)

Serializes payload data for the request to the MQTT CreateCertificateFromCsr service API, in the passed buffer.

Parameters
[in]pCertificateSigningRequestThe Certificate-Signing Request string to serialize for the request.
[in]csrLengthThe length of the Certificate-Signing Request string.
[in,out]pSerializationBufferThe buffer for storing the serialized payload data.
[in]pBufferSizeTHe size of the serialization buffer.
Returns
AWS_IOT_PROVISIONING_SUCCESS if calculation of the payload size is successful; otherwise the appropriate error code.

◆ _AwsIotProvisioning_SerializeRegisterThingRequestPayload()

AwsIotProvisioningError_t _AwsIotProvisioning_SerializeRegisterThingRequestPayload ( const AwsIotProvisioningRegisterThingRequestInfo_t pRequestData,
uint8_t **  pSerializationBuffer,
size_t *  pBufferSize 
)

Serializes payload data for MQTT request to the Provisioning RegisterThing service API.

Parameters
[in]pRequestDataThe data that will be serialized for sending with the request.
[out]pSerializationBufferThis will be assigned to a buffer that will be allocated and populated with the serialized payload data.
Note
The calling code is responsible for de-allocation of the buffer memory.
Parameters
[out]pBufferSizeThis will be populated with the size of the allocated payload data buffer.
Returns
AWS_IOT_PROVISIONING_SUCCESS if serialization is successful; otherwise AWS_IOT_PROVISIONING_INTERNAL_FAILURE for any serialization error.

◆ _AwsIotProvisioning_GenerateRegisterThingTopicFilter()

size_t _AwsIotProvisioning_GenerateRegisterThingTopicFilter ( const char *  pTemplateName,
size_t  templateNameLength,
char *  pTopicFilterBuffer 
)

Utility for generating the request/response MQTT topic filter string for the ProvisioningDevice service API.

Parameters
[in]pTemplateNameThe template ID string for inserting in the topic filter string.
[in]templateNameLengthThe length of the template ID string.
[out]pTopicFilterBufferThe pre-allocated buffer for storing the generated topic filter. The buffer should have the required minimum size for storing the MQTT topic filter for the Provisioning RegisterThing API.
Returns
Returns the size of the generated topic filter.