Classes | Macros | Functions | Variables
MQTTProperties.c File Reference
#include "MQTTProperties.h"
#include "MQTTPacket.h"
#include "MQTTProtocolClient.h"
#include "Heap.h"
#include "StackTrace.h"
#include <memory.h>
Include dependency graph for MQTTProperties.c:

Go to the source code of this file.

Classes

struct  nameToType
 

Macros

#define ARRAY_SIZE(a)   (sizeof(a) / sizeof(a[0]))
 

Functions

static char * datadup (const MQTTLenString *str)
 
int MQTTProperties_add (MQTTProperties *props, const MQTTProperty *prop)
 
MQTTProperties MQTTProperties_copy (const MQTTProperties *props)
 
void MQTTProperties_free (MQTTProperties *props)
 
int MQTTProperties_getNumericValue (MQTTProperties *props, enum MQTTPropertyCodes propid)
 
int MQTTProperties_getNumericValueAt (MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
 
MQTTPropertyMQTTProperties_getProperty (MQTTProperties *props, enum MQTTPropertyCodes propid)
 
MQTTPropertyMQTTProperties_getPropertyAt (MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
 
int MQTTProperties_hasProperty (MQTTProperties *props, enum MQTTPropertyCodes propid)
 
int MQTTProperties_len (MQTTProperties *props)
 
int MQTTProperties_propertyCount (MQTTProperties *props, enum MQTTPropertyCodes propid)
 
int MQTTProperties_read (MQTTProperties *properties, char **pptr, char *enddata)
 
int MQTTProperties_write (char **pptr, const MQTTProperties *properties)
 
int MQTTProperty_getType (enum MQTTPropertyCodes value)
 
int MQTTProperty_read (MQTTProperty *prop, char **pptr, char *enddata)
 
int MQTTProperty_write (char **pptr, MQTTProperty *prop)
 
const char * MQTTPropertyName (enum MQTTPropertyCodes value)
 

Variables

static struct nameToType namesToTypes []
 
struct {
   const char *   name
 
   enum MQTTPropertyCodes   value
 
nameToString []
 

Macro Definition Documentation

#define ARRAY_SIZE (   a)    (sizeof(a) / sizeof(a[0]))

Definition at line 26 of file MQTTProperties.c.

Function Documentation

static char* datadup ( const MQTTLenString str)
static

Definition at line 64 of file MQTTProperties.c.

int MQTTProperties_add ( MQTTProperties props,
const MQTTProperty prop 
)

Add a new property to a property list

Parameters
propsthe property list
propthe new property
Returns
code 0 is success

Definition at line 102 of file MQTTProperties.c.

MQTTProperties MQTTProperties_copy ( const MQTTProperties props)

Copy the contents of a property list, allocating additional memory if needed.

Parameters
propspointer to the property list.
Returns
the duplicated property list.

Definition at line 409 of file MQTTProperties.c.

void MQTTProperties_free ( MQTTProperties properties)

Free all memory allocated to the property list, including any to individual properties.

Parameters
propertiespointer to the property list.

Definition at line 378 of file MQTTProperties.c.

int MQTTProperties_getNumericValue ( MQTTProperties props,
enum MQTTPropertyCodes  propid 
)

Returns the integer value of a specific property. The property given must be a numeric type.

Parameters
propspointer to the property list.
propidthe property id to check for.
Returns
the integer value of the property. -9999999 on failure.

Definition at line 499 of file MQTTProperties.c.

int MQTTProperties_getNumericValueAt ( MQTTProperties props,
enum MQTTPropertyCodes  propid,
int  index 
)

Returns the integer value of a specific property when it's not the only instance. The property given must be a numeric type.

Parameters
propspointer to the property list.
propidthe property id to check for.
indexthe instance number, starting at 0.
Returns
the integer value of the property. -9999999 on failure.

Definition at line 459 of file MQTTProperties.c.

MQTTProperty* MQTTProperties_getProperty ( MQTTProperties props,
enum MQTTPropertyCodes  propid 
)

Returns a pointer to the property structure for a specific property.

Parameters
propspointer to the property list.
propidthe property id to check for.
Returns
the pointer to the property structure if found. NULL if not found.

Definition at line 530 of file MQTTProperties.c.

MQTTProperty* MQTTProperties_getPropertyAt ( MQTTProperties props,
enum MQTTPropertyCodes  propid,
int  index 
)

Returns a pointer to the property structure for a specific property when it's not the only instance.

Parameters
propspointer to the property list.
propidthe property id to check for.
indexthe instance number, starting at 0.
Returns
the pointer to the property structure if found. NULL if not found.

Definition at line 505 of file MQTTProperties.c.

int MQTTProperties_hasProperty ( MQTTProperties props,
enum MQTTPropertyCodes  propid 
)

Checks if property list contains a specific property.

Parameters
propspointer to the property list.
propidthe property id to check for.
Returns
1 if found, 0 if not.

Definition at line 428 of file MQTTProperties.c.

int MQTTProperties_len ( MQTTProperties props)

Returns the length of the properties structure when serialized ready for network transmission.

Parameters
propsan MQTT V5 property structure.
Returns
the length in bytes of the properties when serialized.

Definition at line 89 of file MQTTProperties.c.

int MQTTProperties_propertyCount ( MQTTProperties props,
enum MQTTPropertyCodes  propid 
)

Returns the number of instances of a property id. Most properties can exist only once. User properties and subscription ids can exist more than once.

Parameters
propspointer to the property list.
propidthe property id to check for.
Returns
the number of times found. Can be 0.

Definition at line 445 of file MQTTProperties.c.

int MQTTProperties_read ( MQTTProperties properties,
char **  pptr,
char *  enddata 
)

Reads a property list from a character buffer into an array.

Parameters
propertiespointer to the property list to be filled. Should be initalized but empty.
pptrpointer to the character buffer.
enddatapointer to the end of the character buffer so we don't read beyond.
Returns
1 if the properties were read successfully.

Definition at line 282 of file MQTTProperties.c.

int MQTTProperties_write ( char **  pptr,
const MQTTProperties properties 
)

Serialize the given property list to a character buffer, e.g. for writing to the network.

Parameters
pptrpointer to the buffer - move the pointer as we add data
propertiespointer to the property list, can be NULL
Returns
whether the write succeeded or not: number of bytes written, or < 0 on failure.

Definition at line 208 of file MQTTProperties.c.

int MQTTProperty_getType ( enum MQTTPropertyCodes  value)

Returns the MQTT V5 type code of an MQTT V5 property.

Parameters
valuean MQTT V5 property code.
Returns
the MQTT V5 type code of the input property. -1 if the code was not found.

Definition at line 73 of file MQTTProperties.c.

int MQTTProperty_read ( MQTTProperty prop,
char **  pptr,
char *  enddata 
)

Definition at line 238 of file MQTTProperties.c.

int MQTTProperty_write ( char **  pptr,
MQTTProperty prop 
)

Definition at line 165 of file MQTTProperties.c.

const char* MQTTPropertyName ( enum MQTTPropertyCodes  value)

Returns a printable string description of an MQTT V5 property code.

Parameters
valuean MQTT V5 property code.
Returns
the printable string description of the input property code. NULL if the code was not found.

Definition at line 361 of file MQTTProperties.c.

Variable Documentation

const char* name

Definition at line 329 of file MQTTProperties.c.

struct nameToType namesToTypes[]
static
Initial value:
=
{
{MQTTPROPERTY_CODE_RESPONSE_TOPIC, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL, MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER},
{MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_AUTHENTICATION_METHOD, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_AUTHENTICATION_DATA, MQTTPROPERTY_TYPE_BINARY_DATA},
{MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL, MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER},
{MQTTPROPERTY_CODE_RESPONSE_INFORMATION, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_SERVER_REFERENCE, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_REASON_STRING, MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING},
{MQTTPROPERTY_CODE_RECEIVE_MAXIMUM, MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER},
{MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM, MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER},
{MQTTPROPERTY_CODE_TOPIC_ALIAS, MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER},
{MQTTPROPERTY_CODE_MAXIMUM_QOS, MQTTPROPERTY_TYPE_BYTE},
{MQTTPROPERTY_CODE_RETAIN_AVAILABLE, MQTTPROPERTY_TYPE_BYTE},
{MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE, MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER},
}
struct { ... } nameToString[]
Initial value:
=
{
{MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR, "PAYLOAD_FORMAT_INDICATOR"},
{MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL, "MESSAGE_EXPIRY_INTERVAL"},
{MQTTPROPERTY_CODE_CONTENT_TYPE, "CONTENT_TYPE"},
{MQTTPROPERTY_CODE_RESPONSE_TOPIC, "RESPONSE_TOPIC"},
{MQTTPROPERTY_CODE_CORRELATION_DATA, "CORRELATION_DATA"},
{MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER, "SUBSCRIPTION_IDENTIFIER"},
{MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL, "SESSION_EXPIRY_INTERVAL"},
{MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER, "ASSIGNED_CLIENT_IDENTIFER"},
{MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE, "SERVER_KEEP_ALIVE"},
{MQTTPROPERTY_CODE_AUTHENTICATION_METHOD, "AUTHENTICATION_METHOD"},
{MQTTPROPERTY_CODE_AUTHENTICATION_DATA, "AUTHENTICATION_DATA"},
{MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION, "REQUEST_PROBLEM_INFORMATION"},
{MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL, "WILL_DELAY_INTERVAL"},
{MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION, "REQUEST_RESPONSE_INFORMATION"},
{MQTTPROPERTY_CODE_RESPONSE_INFORMATION, "RESPONSE_INFORMATION"},
{MQTTPROPERTY_CODE_SERVER_REFERENCE, "SERVER_REFERENCE"},
{MQTTPROPERTY_CODE_REASON_STRING, "REASON_STRING"},
{MQTTPROPERTY_CODE_RECEIVE_MAXIMUM, "RECEIVE_MAXIMUM"},
{MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM, "TOPIC_ALIAS_MAXIMUM"},
{MQTTPROPERTY_CODE_RETAIN_AVAILABLE, "RETAIN_AVAILABLE"},
{MQTTPROPERTY_CODE_USER_PROPERTY, "USER_PROPERTY"},
{MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE, "MAXIMUM_PACKET_SIZE"},
{MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE, "WILDCARD_SUBSCRIPTION_AVAILABLE"},
{MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE, "SUBSCRIPTION_IDENTIFIERS_AVAILABLE"},
{MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE, "SHARED_SUBSCRIPTION_AVAILABLE"}
}
enum MQTTPropertyCodes value

Definition at line 328 of file MQTTProperties.c.



plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:49