AWS IoT Device SDK C: MQTT
MQTT 3.1.1 client library
Return to main page ↑
iot_mqtt_validate.c File Reference

Implements functions that validate the structs of the MQTT library. More...

#include "iot_config.h"
#include "private/iot_mqtt_internal.h"

Functions

static bool _validatePublish (bool awsIotMqttMode, size_t maximumPayloadLength, const char *pPublishTypeDescription, const IotMqttPublishInfo_t *pPublishInfo)
 Check that an IotMqttPublishInfo_t is valid. More...
 
static bool _validatePublishPayload (const IotMqttPublishInfo_t *pPublishInfo, size_t maximumPayloadLength, const char *pPublishTypeDescription)
 Check that the payload inside IotMqttPublishInfo_t is valid. More...
 
static bool _validateQos (IotMqttQos_t qos)
 Check that an IotMqttQos_t is valid. More...
 
static bool _validateString (const char *pString, uint16_t length)
 Check that a string is valid. More...
 
static bool _validateListSize (bool awsIotMqttMode, const IotMqttSubscription_t *pListStart, size_t listSize)
 Check that a list of subscriptions is valid. More...
 
static bool _validateSubscription (bool awsIotMqttMode, IotMqttOperationType_t operation, const IotMqttSubscription_t *pSubscription)
 Check that a single subscription is valid. More...
 
static bool _validateWildcardPlus (uint16_t index, const IotMqttSubscription_t *pSubscription)
 Check that the MQTT + wildcard is being used correctly. More...
 
static bool _validateWildcardHash (uint16_t index, const IotMqttSubscription_t *pSubscription)
 Check that the MQTT # wildcard is being used correctly. More...
 
static bool _validateClientId (const IotMqttConnectInfo_t *pConnectInfo)
 Validate the MQTT client identifier. More...
 
bool _IotMqtt_ValidateConnect (const IotMqttConnectInfo_t *pConnectInfo)
 Check that an IotMqttConnectInfo_t is valid. More...
 
bool _IotMqtt_ValidatePublish (bool awsIotMqttMode, const IotMqttPublishInfo_t *pPublishInfo, uint32_t flags, const IotMqttCallbackInfo_t *pCallbackInfo, const IotMqttOperation_t *const pPublishOperation)
 Check that parameters for an MQTT PUBLISH are valid. More...
 
bool _IotMqtt_ValidateLwtPublish (bool awsIotMqttMode, const IotMqttPublishInfo_t *pLwtPublishInfo)
 Check that an IotMqttPublishInfo_t is valid for an LWT publish. More...
 
bool _IotMqtt_ValidateOperation (IotMqttOperation_t operation)
 Check that an IotMqttOperation_t is valid and waitable. More...
 
bool _IotMqtt_ValidateSubscriptionList (IotMqttOperationType_t operation, bool awsIotMqttMode, const IotMqttSubscription_t *pListStart, size_t listSize)
 Check that a list of IotMqttSubscription_t is valid. More...
 

Detailed Description

Implements functions that validate the structs of the MQTT library.

Function Documentation

◆ _validatePublish()

static bool _validatePublish ( bool  awsIotMqttMode,
size_t  maximumPayloadLength,
const char *  pPublishTypeDescription,
const IotMqttPublishInfo_t pPublishInfo 
)
static

Check that an IotMqttPublishInfo_t is valid.

Parameters
[in]awsIotMqttModeSpecifies if this PUBLISH packet is being sent to an AWS IoT MQTT server.
[in]maximumPayloadLengthMaximum payload length.
[in]pPublishTypeDescriptionString describing the publish type.
[in]pPublishInfoThe IotMqttPublishInfo_t to validate.
Returns
true if pPublishInfo is valid; false otherwise.

◆ _validatePublishPayload()

static bool _validatePublishPayload ( const IotMqttPublishInfo_t pPublishInfo,
size_t  maximumPayloadLength,
const char *  pPublishTypeDescription 
)
static

Check that the payload inside IotMqttPublishInfo_t is valid.

Parameters
[in]pPublishInfoThe IotMqttPublishInfo_t to validate.
[in]maximumPayloadLengthMaximum payload length.
[in]pPublishTypeDescriptionString describing the publish type.
Returns
true if payload is valid; false otherwise

◆ _validateQos()

static bool _validateQos ( IotMqttQos_t  qos)
static

Check that an IotMqttQos_t is valid.

Parameters
[in]qosThe QoS to check.
Returns
true if qos is valid; false otherwise.

◆ _validateString()

static bool _validateString ( const char *  pString,
uint16_t  length 
)
static

Check that a string is valid.

Parameters
[in]pStringThe string to check.
[in]lengthLength of string to check.
Returns
true if pString is valid; false otherwise.

◆ _validateListSize()

static bool _validateListSize ( bool  awsIotMqttMode,
const IotMqttSubscription_t pListStart,
size_t  listSize 
)
static

Check that a list of subscriptions is valid.

Parameters
[in]awsIotMqttModeWhether to enforce list length restrictions from AWS IoT.
[in]pListStartFirst element of the list.
[in]listSizeLength of the list.
Returns
true if pListStart is valid; false otherwise.

◆ _validateSubscription()

static bool _validateSubscription ( bool  awsIotMqttMode,
IotMqttOperationType_t  operation,
const IotMqttSubscription_t pSubscription 
)
static

Check that a single subscription is valid.

Parameters
[in]awsIotMqttModeWhether to enforce the topic filter restrictions from AWS IoT.
[in]operationEither IOT_MQTT_SUBSCRIBE or IOT_MQTT_UNSUBSCRIBE.
[in]pSubscriptionThe subscription to check.
Returns
true if pSubscription is valid; false otherwise.

◆ _validateWildcardPlus()

static bool _validateWildcardPlus ( uint16_t  index,
const IotMqttSubscription_t pSubscription 
)
static

Check that the MQTT + wildcard is being used correctly.

Parameters
[in]indexIndex of + in the topic filter.
[in]pSubscriptionSubscription with the topic filter to check.
Returns
true if the + wildcard is valid; false otherwise.

◆ _validateWildcardHash()

static bool _validateWildcardHash ( uint16_t  index,
const IotMqttSubscription_t pSubscription 
)
static

Check that the MQTT # wildcard is being used correctly.

Parameters
[in]indexIndex of # in the topic filter.
[in]pSubscriptionSubscription with the topic filter to check.
Returns
true if the # wildcard is valid; false otherwise.

◆ _validateClientId()

static bool _validateClientId ( const IotMqttConnectInfo_t pConnectInfo)
static

Validate the MQTT client identifier.

Parameters
[in]pConnectInfoThe IotMqttConnectInfo_t containing the client identifier to validate.
Returns
true if client identifier is valid, false otherwise.

◆ _IotMqtt_ValidateConnect()

bool _IotMqtt_ValidateConnect ( const IotMqttConnectInfo_t pConnectInfo)

Check that an IotMqttConnectInfo_t is valid.

Parameters
[in]pConnectInfoThe IotMqttConnectInfo_t to validate.
Returns
true if pConnectInfo is valid; false otherwise.

◆ _IotMqtt_ValidatePublish()

bool _IotMqtt_ValidatePublish ( bool  awsIotMqttMode,
const IotMqttPublishInfo_t pPublishInfo,
uint32_t  flags,
const IotMqttCallbackInfo_t pCallbackInfo,
const IotMqttOperation_t *const  pPublishOperation 
)

Check that parameters for an MQTT PUBLISH are valid.

Parameters
[in]awsIotMqttModeSpecifies if this PUBLISH packet is being sent to an AWS IoT MQTT server.
[in]pPublishInfoThe IotMqttPublishInfo_t to validate.
[in]flagsBehavior modification flags to validate. See MQTT Function Flags.
[in]pCallbackInfoIotMqttCallbackInfo_t to validate.
[in]pPublishOperationHandle to a PUBLISH operation.
Returns
true if all parameters are valid; false otherwise.

◆ _IotMqtt_ValidateLwtPublish()

bool _IotMqtt_ValidateLwtPublish ( bool  awsIotMqttMode,
const IotMqttPublishInfo_t pLwtPublishInfo 
)

Check that an IotMqttPublishInfo_t is valid for an LWT publish.

Parameters
[in]awsIotMqttModeSpecifies if this PUBLISH packet is being sent to an AWS IoT MQTT server.
[in]pLwtPublishInfoThe IotMqttPublishInfo_t to validate.
Returns
true if pLwtPublishInfo is valid; false otherwise.

◆ _IotMqtt_ValidateOperation()

bool _IotMqtt_ValidateOperation ( IotMqttOperation_t  operation)

Check that an IotMqttOperation_t is valid and waitable.

Parameters
[in]operationThe IotMqttOperation_t to validate.
Returns
true if operation is valid; false otherwise.

◆ _IotMqtt_ValidateSubscriptionList()

bool _IotMqtt_ValidateSubscriptionList ( IotMqttOperationType_t  operation,
bool  awsIotMqttMode,
const IotMqttSubscription_t pListStart,
size_t  listSize 
)

Check that a list of IotMqttSubscription_t is valid.

Parameters
[in]operationEither IOT_MQTT_SUBSCRIBE or IOT_MQTT_UNSUBSCRIBE. Some parameters are not validated for IOT_MQTT_UNSUBSCRIBE.
[in]awsIotMqttModeSpecifies if this SUBSCRIBE packet is being sent to an AWS IoT MQTT server.
[in]pListStartFirst element of the list to validate.
[in]listSizeNumber of elements in the subscription list.
Returns
true if every element in the list is valid; false otherwise.