Paho MQTT C Client Library: MQTTProperties.h Source File

| Paho MQTT C Client Library

Loading...
Searching...
No Matches
MQTTProperties.h
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (c) 2017, 2024 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#include <stdint.h>
23
24#define MQTT_INVALID_PROPERTY_ID -2
25
27 enum MQTTPropertyCodes {
28 MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR = 1,
29 MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL = 2,
30 MQTTPROPERTY_CODE_CONTENT_TYPE = 3,
31 MQTTPROPERTY_CODE_RESPONSE_TOPIC = 8,
32 MQTTPROPERTY_CODE_CORRELATION_DATA = 9,
33 MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER = 11,
34 MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL = 17,
35 MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER = 18,
36 MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER = 18,
37 MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE = 19,
38 MQTTPROPERTY_CODE_AUTHENTICATION_METHOD = 21,
39 MQTTPROPERTY_CODE_AUTHENTICATION_DATA = 22,
40 MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION = 23,
41 MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL = 24,
42 MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION = 25,
43 MQTTPROPERTY_CODE_RESPONSE_INFORMATION = 26,
44 MQTTPROPERTY_CODE_SERVER_REFERENCE = 28,
45 MQTTPROPERTY_CODE_REASON_STRING = 31,
46 MQTTPROPERTY_CODE_RECEIVE_MAXIMUM = 33,
47 MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM = 34,
48 MQTTPROPERTY_CODE_TOPIC_ALIAS = 35,
49 MQTTPROPERTY_CODE_MAXIMUM_QOS = 36,
50 MQTTPROPERTY_CODE_RETAIN_AVAILABLE = 37,
51 MQTTPROPERTY_CODE_USER_PROPERTY = 38,
52 MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE = 39,
53 MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE = 40,
54 MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE = 41,
55 MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE = 42
56};
57
64LIBMQTT_API const char* MQTTPropertyName(enum MQTTPropertyCodes value);
65
67 enum MQTTPropertyTypes {
68 MQTTPROPERTY_TYPE_BYTE,
69 MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER,
70 MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER,
71 MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER,
72 MQTTPROPERTY_TYPE_BINARY_DATA,
73 MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING,
74 MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
75};
76
82LIBMQTT_API int MQTTProperty_getType(enum MQTTPropertyCodes value);
83
87 typedef struct
88{
89 int len;
90 char* data;
91} MQTTLenString;
92
93
97 typedef struct
98{
99 enum MQTTPropertyCodes identifier;
101 union {
102 unsigned char byte;
103 unsigned short integer2;
104 unsigned int integer4;
105 struct {
106 MQTTLenString data;
107 MQTTLenString value;
108 };
109 } value;
110} MQTTProperty;
111
115 typedef struct MQTTProperties
116{
117 int count;
118 int max_count;
119 int length;
120 MQTTProperty *array;
121} MQTTProperties;
122
123#define MQTTProperties_initializer {0, 0, 0, NULL}
124
130 int MQTTProperties_len(const MQTTProperties* props);
131
141LIBMQTT_API int MQTTProperties_add(MQTTProperties* props, const MQTTProperty* prop);
142
149 int MQTTProperties_write(char** pptr, const MQTTProperties* properties);
150
158 int MQTTProperties_read(MQTTProperties* properties, char** pptr, char* enddata);
159
164LIBMQTT_API void MQTTProperties_free(MQTTProperties* properties);
165
171LIBMQTT_API MQTTProperties MQTTProperties_copy(const MQTTProperties* props);
172
179LIBMQTT_API int MQTTProperties_hasProperty(const MQTTProperties *props, enum MQTTPropertyCodes propid);
180
188LIBMQTT_API int MQTTProperties_propertyCount(const MQTTProperties *props, enum MQTTPropertyCodes propid);
189
196LIBMQTT_API int64_t MQTTProperties_getNumericValue(const MQTTProperties *props, enum MQTTPropertyCodes propid);
197
206LIBMQTT_API int64_t MQTTProperties_getNumericValueAt(const MQTTProperties *props, enum MQTTPropertyCodes propid, int index);
207
214LIBMQTT_API MQTTProperty* MQTTProperties_getProperty(const MQTTProperties *props, enum MQTTPropertyCodes propid);
215
223LIBMQTT_API MQTTProperty* MQTTProperties_getPropertyAt(const MQTTProperties *props, enum MQTTPropertyCodes propid, int index);
224
225#endif /* MQTTPROPERTIES_H */
MQTTProperties_getNumericValueAt
int64_t MQTTProperties_getNumericValueAt(const MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
MQTTProperties_len
int MQTTProperties_len(const MQTTProperties *props)
MQTTProperties_getPropertyAt
MQTTProperty * MQTTProperties_getPropertyAt(const MQTTProperties *props, enum MQTTPropertyCodes propid, int index)
MQTTProperties_copy
MQTTProperties MQTTProperties_copy(const MQTTProperties *props)
MQTTPropertyName
const char * MQTTPropertyName(enum MQTTPropertyCodes value)
MQTTProperty_getType
int MQTTProperty_getType(enum MQTTPropertyCodes value)
MQTTProperties_add
int MQTTProperties_add(MQTTProperties *props, const MQTTProperty *prop)
MQTTPropertyTypes
MQTTPropertyTypes
Definition MQTTProperties.h:67
MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_VARIABLE_BYTE_INTEGER
Definition MQTTProperties.h:71
MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
@ MQTTPROPERTY_TYPE_UTF_8_STRING_PAIR
Definition MQTTProperties.h:74
MQTTPROPERTY_TYPE_BINARY_DATA
@ MQTTPROPERTY_TYPE_BINARY_DATA
Definition MQTTProperties.h:72
MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_FOUR_BYTE_INTEGER
Definition MQTTProperties.h:70
MQTTPROPERTY_TYPE_BYTE
@ MQTTPROPERTY_TYPE_BYTE
Definition MQTTProperties.h:68
MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING
@ MQTTPROPERTY_TYPE_UTF_8_ENCODED_STRING
Definition MQTTProperties.h:73
MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER
@ MQTTPROPERTY_TYPE_TWO_BYTE_INTEGER
Definition MQTTProperties.h:69
MQTTProperties_free
void MQTTProperties_free(MQTTProperties *properties)
MQTTProperties_hasProperty
int MQTTProperties_hasProperty(const MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_getProperty
MQTTProperty * MQTTProperties_getProperty(const MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_propertyCount
int MQTTProperties_propertyCount(const MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_getNumericValue
int64_t MQTTProperties_getNumericValue(const MQTTProperties *props, enum MQTTPropertyCodes propid)
MQTTProperties_write
int MQTTProperties_write(char **pptr, const MQTTProperties *properties)
MQTTPropertyCodes
MQTTPropertyCodes
Definition MQTTProperties.h:27
MQTTPROPERTY_CODE_SERVER_REFERENCE
@ MQTTPROPERTY_CODE_SERVER_REFERENCE
Definition MQTTProperties.h:44
MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM
@ MQTTPROPERTY_CODE_TOPIC_ALIAS_MAXIMUM
Definition MQTTProperties.h:47
MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL
@ MQTTPROPERTY_CODE_SESSION_EXPIRY_INTERVAL
Definition MQTTProperties.h:34
MQTTPROPERTY_CODE_RESPONSE_INFORMATION
@ MQTTPROPERTY_CODE_RESPONSE_INFORMATION
Definition MQTTProperties.h:43
MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL
@ MQTTPROPERTY_CODE_MESSAGE_EXPIRY_INTERVAL
Definition MQTTProperties.h:29
MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION
@ MQTTPROPERTY_CODE_REQUEST_PROBLEM_INFORMATION
Definition MQTTProperties.h:40
MQTTPROPERTY_CODE_REASON_STRING
@ MQTTPROPERTY_CODE_REASON_STRING
Definition MQTTProperties.h:45
MQTTPROPERTY_CODE_CONTENT_TYPE
@ MQTTPROPERTY_CODE_CONTENT_TYPE
Definition MQTTProperties.h:30
MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION
@ MQTTPROPERTY_CODE_REQUEST_RESPONSE_INFORMATION
Definition MQTTProperties.h:42
MQTTPROPERTY_CODE_RETAIN_AVAILABLE
@ MQTTPROPERTY_CODE_RETAIN_AVAILABLE
Definition MQTTProperties.h:50
MQTTPROPERTY_CODE_MAXIMUM_QOS
@ MQTTPROPERTY_CODE_MAXIMUM_QOS
Definition MQTTProperties.h:49
MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL
@ MQTTPROPERTY_CODE_WILL_DELAY_INTERVAL
Definition MQTTProperties.h:41
MQTTPROPERTY_CODE_USER_PROPERTY
@ MQTTPROPERTY_CODE_USER_PROPERTY
Definition MQTTProperties.h:51
MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE
@ MQTTPROPERTY_CODE_MAXIMUM_PACKET_SIZE
Definition MQTTProperties.h:52
MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER
@ MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIER
Definition MQTTProperties.h:33
MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER
@ MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFER
Definition MQTTProperties.h:36
MQTTPROPERTY_CODE_AUTHENTICATION_METHOD
@ MQTTPROPERTY_CODE_AUTHENTICATION_METHOD
Definition MQTTProperties.h:38
MQTTPROPERTY_CODE_RESPONSE_TOPIC
@ MQTTPROPERTY_CODE_RESPONSE_TOPIC
Definition MQTTProperties.h:31
MQTTPROPERTY_CODE_CORRELATION_DATA
@ MQTTPROPERTY_CODE_CORRELATION_DATA
Definition MQTTProperties.h:32
MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE
@ MQTTPROPERTY_CODE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE
Definition MQTTProperties.h:54
MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE
@ MQTTPROPERTY_CODE_SERVER_KEEP_ALIVE
Definition MQTTProperties.h:37
MQTTPROPERTY_CODE_RECEIVE_MAXIMUM
@ MQTTPROPERTY_CODE_RECEIVE_MAXIMUM
Definition MQTTProperties.h:46
MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER
@ MQTTPROPERTY_CODE_ASSIGNED_CLIENT_IDENTIFIER
Definition MQTTProperties.h:35
MQTTPROPERTY_CODE_AUTHENTICATION_DATA
@ MQTTPROPERTY_CODE_AUTHENTICATION_DATA
Definition MQTTProperties.h:39
MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE
@ MQTTPROPERTY_CODE_WILDCARD_SUBSCRIPTION_AVAILABLE
Definition MQTTProperties.h:53
MQTTPROPERTY_CODE_TOPIC_ALIAS
@ MQTTPROPERTY_CODE_TOPIC_ALIAS
Definition MQTTProperties.h:48
MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE
@ MQTTPROPERTY_CODE_SHARED_SUBSCRIPTION_AVAILABLE
Definition MQTTProperties.h:55
MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR
@ MQTTPROPERTY_CODE_PAYLOAD_FORMAT_INDICATOR
Definition MQTTProperties.h:28
MQTTProperties_read
int MQTTProperties_read(MQTTProperties *properties, char **pptr, char *enddata)
MQTTLenString
Definition MQTTProperties.h:88
MQTTLenString::data
char * data
Definition MQTTProperties.h:90
MQTTLenString::len
int len
Definition MQTTProperties.h:89
MQTTProperties
Definition MQTTProperties.h:116
MQTTProperties::array
MQTTProperty * array
Definition MQTTProperties.h:120
MQTTProperties::max_count
int max_count
Definition MQTTProperties.h:118
MQTTProperties::length
int length
Definition MQTTProperties.h:119
MQTTProperties::count
int count
Definition MQTTProperties.h:117
MQTTProperty
Definition MQTTProperties.h:98
MQTTProperty::integer2
unsigned short integer2
Definition MQTTProperties.h:103
MQTTProperty::value
MQTTLenString value
Definition MQTTProperties.h:107
MQTTProperty::byte
unsigned char byte
Definition MQTTProperties.h:102
MQTTProperty::identifier
enum MQTTPropertyCodes identifier
Definition MQTTProperties.h:99
MQTTProperty::integer4
unsigned int integer4
Definition MQTTProperties.h:104
MQTTProperty::data
MQTTLenString data
Definition MQTTProperties.h:106