Paho MQTT C Client Library: MQTTProperties.h Source File

| Paho MQTT C Client Library

MQTTProperties.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (c) 2017, 2023 IBM Corp. and others
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v2.0
6 * and Eclipse Distribution License v1.0 which accompany this distribution.
7 *
8 * The Eclipse Public License is available at
9 * https://www.eclipse.org/legal/epl-2.0/
10 * and the Eclipse Distribution License is available at
11 * http://www.eclipse.org/org/documents/edl-v10.php.
12 *
13 * Contributors:
14 * Ian Craggs - initial API and implementation and/or initial documentation
15 *******************************************************************************/
16
17 #if !defined(MQTTPROPERTIES_H)
18 #define MQTTPROPERTIES_H
19
20 #include "MQTTExportDeclarations.h"
21
22 #define MQTT_INVALID_PROPERTY_ID -2
23
25 enum MQTTPropertyCodes {
26 MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR = 1,
27 MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL = 2,
28 MQTTPROPERTY_CODE_CONTENT_TYPE = 3,
29 MQTTPROPERTY_CODE_RESPONSE_TOPIC = 8,
30 MQTTPROPERTY_CODE_CORRELATION_DATA = 9,
31 MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER = 11,
32 MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL = 17,
33 MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER = 18,
34 MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE = 19,
35 MQTTPROPERTY_CODE_AUTHENTICATION_METHOD = 21,
36 MQTTPROPERTY_CODE_AUTHENTICATION_DATA = 22,
37 MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION = 23,
38 MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL = 24,
39 MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION = 25,
40 MQTTPROPERTY_CODE_RESPONSE_INFORMATION = 26,
41 MQTTPROPERTY_CODE_SERVER_REFERENCE = 28,
42 MQTTPROPERTY_CODE_REASON_STRING = 31,
43 MQTTPROPERTY_CODE_RECEIVE_MAXIMUM = 33,
44 MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM = 34,
45 MQTTPROPERTY_CODE_TOPIC_ALIAS = 35,
46 MQTTPROPERTY_CODE_MAXIMUM_QOS = 36,
47 MQTTPROPERTY_CODE_RETAIN_AVAILABLE = 37,
48 MQTTPROPERTY_CODE_USER_PROPERTY = 38,
49 MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE = 39,
50 MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE = 40,
51 MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE = 41,
52 MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE = 42
53 };
54
61 LIBMQTT_API const char* MQTTPropertyName(enum MQTTPropertyCodes value);
62
64 enum MQTTPropertyTypes {
65 MQTTPROPERTY_TYPE_BYTE,
66 MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER,
67 MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER,
68 MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER,
69 MQTTPROPERTY_TYPE_BINARY_DATA,
70 MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING,
71 MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
72 };
73
79 LIBMQTT_API int MQTTProperty_getType(enum MQTTPropertyCodes value);
80
84 typedef struct
85 {
86 int len;
87 char* data;
88 } MQTTLenString;
89
90
94 typedef struct
95 {
96 enum MQTTPropertyCodes identifier;
98 union {
99 unsigned char byte;
100 unsigned short integer2;
101 unsigned int integer4;
102 struct {
103 MQTTLenString data;
104 MQTTLenString value;
105 };
106 } value;
107 } MQTTProperty;
108
112 typedef struct MQTTProperties
113 {
114 int count;
115 int max_count;
116 int length;
117 MQTTProperty *array;
118 } MQTTProperties;
119
120 #define MQTTProperties_initializer {0, 0, 0, NULL}
121
127 int MQTTProperties_len(MQTTProperties* props);
128
138 LIBMQTT_API int MQTTProperties_add(MQTTProperties* props, const MQTTProperty* prop);
139
146 int MQTTProperties_write(char** pptr, const MQTTProperties* properties);
147
155 int MQTTProperties_read(MQTTProperties* properties, char** pptr, char* enddata);
156
161 LIBMQTT_API void MQTTProperties_free(MQTTProperties* properties);
162
168 LIBMQTT_API MQTTProperties MQTTProperties_copy(const MQTTProperties* props);
169
176 LIBMQTT_API int MQTTProperties_hasProperty(MQTTProperties *props, enum MQTTPropertyCodes propid);
177
185 LIBMQTT_API int MQTTProperties_propertyCount(MQTTProperties *props, enum MQTTPropertyCodes propid);
186
193 LIBMQTT_API int MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid);
194
203 LIBMQTT_API int MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index);
204
211 LIBMQTT_API MQTTProperty* MQTTProperties_getProperty(MQTTProperties *props, enum MQTTPropertyCodes propid);
212
220 LIBMQTT_API MQTTProperty* MQTTProperties_getPropertyAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index);
221
222 #endif /* MQTTPROPERTIES_H */
MQTTProperties_hasProperty
int MQTTProperties_hasProperty(MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_copy
MQTTProperties MQTTProperties_copy(const MQTTProperties *props)
MQTTProperties_propertyCount
int MQTTProperties_propertyCount(MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties
struct MQTTProperties MQTTProperties
MQTTProperties_getProperty
MQTTProperty * MQTTProperties_getProperty(MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperty_getType
int MQTTProperty_getType(enum MQTTPropertyCodes value)
MQTTProperties_add
int MQTTProperties_add(MQTTProperties *props, const MQTTProperty *prop)
MQTTPropertyTypes
MQTTPropertyTypes
Definition: MQTTProperties.h:64
MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER
Definition: MQTTProperties.h:68
MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
@ MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
Definition: MQTTProperties.h:71
MQTTPROPERTY_TYPE_BINARY_DATA
@ MQTTPROPERTY_TYPE_BINARY_DATA
Definition: MQTTProperties.h:69
MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER
Definition: MQTTProperties.h:67
MQTTPROPERTY_TYPE_BYTE
@ MQTTPROPERTY_TYPE_BYTE
Definition: MQTTProperties.h:65
MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING
@ MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING
Definition: MQTTProperties.h:70
MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER
Definition: MQTTProperties.h:66
MQTTProperties_free
void MQTTProperties_free(MQTTProperties *properties)
MQTTProperties_len
int MQTTProperties_len(MQTTProperties *props)
MQTTProperties_getNumericValueAt
int MQTTProperties_getNumericValueAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
MQTTProperties_getPropertyAt
MQTTProperty * MQTTProperties_getPropertyAt(MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
MQTTProperties_write
int MQTTProperties_write(char **pptr, const MQTTProperties *properties)
MQTTPropertyCodes
MQTTPropertyCodes
Definition: MQTTProperties.h:25
MQTTPROPERTY_CODE_SERVER_REFERENCE
@ MQTTPROPERTY_CODE_SERVER_REFERENCE
Definition: MQTTProperties.h:41
MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM
@ MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM
Definition: MQTTProperties.h:44
MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL
@ MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL
Definition: MQTTProperties.h:32
MQTTPROPERTY_CODE_RESPONSE_INFORMATION
@ MQTTPROPERTY_CODE_RESPONSE_INFORMATION
Definition: MQTTProperties.h:40
MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL
@ MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL
Definition: MQTTProperties.h:27
MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION
@ MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION
Definition: MQTTProperties.h:37
MQTTPROPERTY_CODE_REASON_STRING
@ MQTTPROPERTY_CODE_REASON_STRING
Definition: MQTTProperties.h:42
MQTTPROPERTY_CODE_CONTENT_TYPE
@ MQTTPROPERTY_CODE_CONTENT_TYPE
Definition: MQTTProperties.h:28
MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION
@ MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION
Definition: MQTTProperties.h:39
MQTTPROPERTY_CODE_RETAIN_AVAILABLE
@ MQTTPROPERTY_CODE_RETAIN_AVAILABLE
Definition: MQTTProperties.h:47
MQTTPROPERTY_CODE_MAXIMUM_QOS
@ MQTTPROPERTY_CODE_MAXIMUM_QOS
Definition: MQTTProperties.h:46
MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL
@ MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL
Definition: MQTTProperties.h:38
MQTTPROPERTY_CODE_USER_PROPERTY
@ MQTTPROPERTY_CODE_USER_PROPERTY
Definition: MQTTProperties.h:48
MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE
@ MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE
Definition: MQTTProperties.h:49
MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER
@ MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER
Definition: MQTTProperties.h:31
MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER
@ MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER
Definition: MQTTProperties.h:33
MQTTPROPERTY_CODE_AUTHENTICATION_METHOD
@ MQTTPROPERTY_CODE_AUTHENTICATION_METHOD
Definition: MQTTProperties.h:35
MQTTPROPERTY_CODE_RESPONSE_TOPIC
@ MQTTPROPERTY_CODE_RESPONSE_TOPIC
Definition: MQTTProperties.h:29
MQTTPROPERTY_CODE_CORRELATION_DATA
@ MQTTPROPERTY_CODE_CORRELATION_DATA
Definition: MQTTProperties.h:30
MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE
@ MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE
Definition: MQTTProperties.h:51
MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE
@ MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE
Definition: MQTTProperties.h:34
MQTTPROPERTY_CODE_RECEIVE_MAXIMUM
@ MQTTPROPERTY_CODE_RECEIVE_MAXIMUM
Definition: MQTTProperties.h:43
MQTTPROPERTY_CODE_AUTHENTICATION_DATA
@ MQTTPROPERTY_CODE_AUTHENTICATION_DATA
Definition: MQTTProperties.h:36
MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE
@ MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE
Definition: MQTTProperties.h:50
MQTTPROPERTY_CODE_TOPIC_ALIAS
@ MQTTPROPERTY_CODE_TOPIC_ALIAS
Definition: MQTTProperties.h:45
MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE
@ MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE
Definition: MQTTProperties.h:52
MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR
@ MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR
Definition: MQTTProperties.h:26
MQTTPropertyName
const char * MQTTPropertyName(enum MQTTPropertyCodes value)
MQTTProperties_getNumericValue
int MQTTProperties_getNumericValue(MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_read
int MQTTProperties_read(MQTTProperties *properties, char **pptr, char *enddata)
MQTTLenString
Definition: MQTTProperties.h:85
MQTTLenString::data
char * data
Definition: MQTTProperties.h:87
MQTTLenString::len
int len
Definition: MQTTProperties.h:86
MQTTProperties
Definition: MQTTProperties.h:113
MQTTProperties::array
MQTTProperty * array
Definition: MQTTProperties.h:117
MQTTProperties::max_count
int max_count
Definition: MQTTProperties.h:115
MQTTProperties::length
int length
Definition: MQTTProperties.h:116
MQTTProperties::count
int count
Definition: MQTTProperties.h:114
MQTTProperty
Definition: MQTTProperties.h:95
MQTTProperty::integer2
unsigned short integer2
Definition: MQTTProperties.h:100
MQTTProperty::value
MQTTLenString value
Definition: MQTTProperties.h:104
MQTTProperty::byte
unsigned char byte
Definition: MQTTProperties.h:99
MQTTProperty::integer4
unsigned int integer4
Definition: MQTTProperties.h:101
MQTTProperty::data
MQTTLenString data
Definition: MQTTProperties.h:103