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

Implements the internal functions for parsing server responses for the Provisioning library. More...

#include "iot_config.h"
#include "iot_error.h"
#include "private/aws_iot_provisioning_internal.h"
#include "iot_logging_setup.h"

Functions

static AwsIotProvisioningError_t _parseRejectedResponse (IotSerializerDecoderObject_t *pPayloadDecoder, const char *pOperationName, AwsIotProvisioningRejectedResponse_t *pResponseData, AwsIotProvisioningServerStatusCode_t *pStatusCode)
 Parses the rejected response payload received from the server, and populates the data of the passed pResponseData parameter. More...
 
static AwsIotProvisioningError_t _parseKeyedEntryInPayload (IotSerializerDecoderObject_t *pPayloadDecoder, IotSerializerDecoderObject_t *pPayloadEntryDecoder, const char *pKeyString, const char *pOperationString)
 Utility for parsing a text-string based key-value pair entry from a map container type response payload. More...
 
static AwsIotProvisioningError_t _parseCommonCertInfoInResponse (IotSerializerDecoderObject_t *pPayloadDecoder, IotSerializerDecoderObject_t *pCertPemDecoder, IotSerializerDecoderObject_t *pCertIdDecoder, IotSerializerDecoderObject_t *pOwnershipTokenDecoder, const char *pOperationString)
 Common utility for parsing the Certificate PEM string, Certificate ID, and Ownership token data from the server response. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_ParseKeysAndCertificateResponse (AwsIotStatus_t responseType, const uint8_t *pResponsePayload, size_t payloadLength, const _provisioningCallbackInfo_t *userCallbackInfo)
 Parses the response received from the server for device credentials, and invokes the provided user-callback with parsed credentials, if parsing was successful. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_ParseCsrResponse (AwsIotStatus_t responseType, const uint8_t *pResponsePayload, size_t payloadLength, const _provisioningCallbackInfo_t *userCallbackInfo)
 Parses the response from the server received on a Certificate-Signing Request, and invokes the provided user-callback with the parsed response. More...
 
AwsIotProvisioningError_t _AwsIotProvisioning_ParseRegisterThingResponse (AwsIotStatus_t responseType, const uint8_t *pResponsePayload, size_t responsePayloadLength, const _provisioningCallbackInfo_t *userCallbackInfo)
 Parses the response payload received from the server for device provisioning, and invokes the provided user-callback with parsed data, if parsing was successful. More...
 

Detailed Description

Implements the internal functions for parsing server responses for the Provisioning library.

Function Documentation

◆ _parseRejectedResponse()

static AwsIotProvisioningError_t _parseRejectedResponse ( IotSerializerDecoderObject_t *  pPayloadDecoder,
const char *  pOperationName,
AwsIotProvisioningRejectedResponse_t pResponseData,
AwsIotProvisioningServerStatusCode_t pStatusCode 
)
static

Parses the rejected response payload received from the server, and populates the data of the passed pResponseData parameter.

Parameters
[in]pPayloadDecoderThe outermost decoder object representing the response payload.
[in]pOperationNameThe Provisioning library operation (or API) that the response is associated with.
[out]pResponseDataThis will be populated with the data parsed from the response payload, if successful.
[out]pStatusCodeThis will be populated with the error status code parsed from the response payload, if successful.
Returns
AWS_IOT_PROVISIONING_SUCCESS, if parsing is successful; otherwise appropriate error message.

◆ _parseKeyedEntryInPayload()

static AwsIotProvisioningError_t _parseKeyedEntryInPayload ( IotSerializerDecoderObject_t *  pPayloadDecoder,
IotSerializerDecoderObject_t *  pPayloadEntryDecoder,
const char *  pKeyString,
const char *  pOperationString 
)
static

Utility for parsing a text-string based key-value pair entry from a map container type response payload.

Parameters
[in]pPayloadDecoderThe decoder object representing the map container formatted payload.
[in,out]pPayloadEntryDecoderThe decoder object to store the parsed value data of the entry.
[in]pKeyStringThe key string to parse from the payload.
[in]pOperationStringThe string of the ongoing operation to use for logging.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS if parsing is successful; otherwise AWS_IOT_PROVISIONING_BAD_RESPONSE if any of the expected data entries is missing in the payload OR AWS_IOT_PROVISIONING_INTERNAL_FAILURE for decoder failures.

◆ _parseCommonCertInfoInResponse()

static AwsIotProvisioningError_t _parseCommonCertInfoInResponse ( IotSerializerDecoderObject_t *  pPayloadDecoder,
IotSerializerDecoderObject_t *  pCertPemDecoder,
IotSerializerDecoderObject_t *  pCertIdDecoder,
IotSerializerDecoderObject_t *  pOwnershipTokenDecoder,
const char *  pOperationString 
)
static

Common utility for parsing the Certificate PEM string, Certificate ID, and Ownership token data from the server response.

Note
These elements are common in the server responses of the MQTT CreateKeysAndCertificate and CreateCertificateFromCsr APIs.
Parameters
[in]pPayloadDecoderThe decoder object that represents the server response payload as a map container.
[in,out]pCertPemDecoderThe decoder object to store the parsed Certificate PEM string in.
[in,out]pCertIdDecoderThe decoder object to store the parsed Certificate ID data in.
[in,out]pOwnershipTokenDecoderThe decoder object to store the parsed Certificate Ownership Token string in.
[in]pOperationStringThe string of the ongoing operation to use for logging.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS if parsing is successful; otherwise AWS_IOT_PROVISIONING_BAD_RESPONSE if any of the expected data entries is missing in the payload OR AWS_IOT_PROVISIONING_INTERNAL_FAILURE for decoder failures.

◆ _AwsIotProvisioning_ParseKeysAndCertificateResponse()

AwsIotProvisioningError_t _AwsIotProvisioning_ParseKeysAndCertificateResponse ( AwsIotStatus_t  responseType,
const uint8_t *  pResponsePayload,
size_t  payloadLength,
const _provisioningCallbackInfo_t userCallbackInfo 
)

Parses the response received from the server for device credentials, and invokes the provided user-callback with parsed credentials, if parsing was successful.

Parameters
[in]responseTypeThe type of response, "accepted" or "rejected" received from the server for the operation.
[in]pResponsePayloadThe response payload from the server to parse.
[in]payloadLengthThe length of the response payload.
[in]userCallbackInfoThe user-provided callback to invoke on successful parsing of response.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS when parsing is successful, otherwise the appropriate error code.

◆ _AwsIotProvisioning_ParseCsrResponse()

AwsIotProvisioningError_t _AwsIotProvisioning_ParseCsrResponse ( AwsIotStatus_t  responseType,
const uint8_t *  pResponsePayload,
size_t  payloadLength,
const _provisioningCallbackInfo_t userCallbackInfo 
)

Parses the response from the server received on a Certificate-Signing Request, and invokes the provided user-callback with the parsed response.

Note
If the server accepts the request, the received certificate information is passed to the user-callback otherwise, the error information is passed on request rejection by the server.
Parameters
[in]responseTypeThe type of response, "accepted" or "rejected" received from the server for the operation.
[in]pResponsePayloadThe response payload from the server to parse.
[in]payloadLengthThe length of the response payload.
[in]userCallbackInfoThe user-provided callback to invoke on successful parsing of response.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS when parsing is successful, otherwise the appropriate error code.

◆ _AwsIotProvisioning_ParseRegisterThingResponse()

AwsIotProvisioningError_t _AwsIotProvisioning_ParseRegisterThingResponse ( AwsIotStatus_t  responseType,
const uint8_t *  pResponsePayload,
size_t  responsePayloadLength,
const _provisioningCallbackInfo_t userCallbackInfo 
)

Parses the response payload received from the server for device provisioning, and invokes the provided user-callback with parsed data, if parsing was successful.

Parameters
[in]responseTypeThe type of response, "accepted" or "rejected" received from the server for the operation.
[in]pResponsePayloadThe response payload from the server to parse.
[in]responsePayloadLengthThe length of the response payload.
[in]userCallbackInfoThe user-provided callback to invoke on successful parsing of response.
Returns
Returns AWS_IOT_PROVISIONING_SUCCESS when parsing is successful, otherwise the appropriate error code.

The serializer library allocates memory for the iterator. It can only be released by iterating to the last element in the map containers and "stepping out" of the container Thus, we will iterate to the end of the device configuration container to invalidate the iterator.