| 1 |
#ifndef AWS_MQTT_MQTT5_UTILS_H |
| 2 |
#define AWS_MQTT_MQTT5_UTILS_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/mqtt/mqtt.h> |
| 10 |
|
| 11 |
#include <aws/mqtt/v5/mqtt5_client.h> |
| 12 |
#include <aws/mqtt/v5/mqtt5_types.h> |
| 13 |
|
| 14 |
struct aws_byte_buf; |
| 15 |
struct aws_mqtt5_negotiated_settings; |
| 16 |
|
| 17 |
#define AWS_MQTT5_MAXIMUM_VARIABLE_LENGTH_INTEGER 268435455 |
| 18 |
#define AWS_MQTT5_MAXIMUM_PACKET_SIZE (5 + AWS_MQTT5_MAXIMUM_VARIABLE_LENGTH_INTEGER) |
| 19 |
#define AWS_MQTT5_RECEIVE_MAXIMUM 65535 |
| 20 |
#define AWS_MQTT5_PINGREQ_ENCODED_SIZE 2 |
| 21 |
|
| 22 |
|
| 23 |
#define AWS_MQTT5_PROPERTY_TYPE_PAYLOAD_FORMAT_INDICATOR ((uint8_t)1) |
| 24 |
#define AWS_MQTT5_PROPERTY_TYPE_MESSAGE_EXPIRY_INTERVAL ((uint8_t)2) |
| 25 |
#define AWS_MQTT5_PROPERTY_TYPE_CONTENT_TYPE ((uint8_t)3) |
| 26 |
#define AWS_MQTT5_PROPERTY_TYPE_RESPONSE_TOPIC ((uint8_t)8) |
| 27 |
#define AWS_MQTT5_PROPERTY_TYPE_CORRELATION_DATA ((uint8_t)9) |
| 28 |
#define AWS_MQTT5_PROPERTY_TYPE_SUBSCRIPTION_IDENTIFIER ((uint8_t)11) |
| 29 |
#define AWS_MQTT5_PROPERTY_TYPE_SESSION_EXPIRY_INTERVAL ((uint8_t)17) |
| 30 |
#define AWS_MQTT5_PROPERTY_TYPE_ASSIGNED_CLIENT_IDENTIFIER ((uint8_t)18) |
| 31 |
#define AWS_MQTT5_PROPERTY_TYPE_SERVER_KEEP_ALIVE ((uint8_t)19) |
| 32 |
#define AWS_MQTT5_PROPERTY_TYPE_AUTHENTICATION_METHOD ((uint8_t)21) |
| 33 |
#define AWS_MQTT5_PROPERTY_TYPE_AUTHENTICATION_DATA ((uint8_t)22) |
| 34 |
#define AWS_MQTT5_PROPERTY_TYPE_REQUEST_PROBLEM_INFORMATION ((uint8_t)23) |
| 35 |
#define AWS_MQTT5_PROPERTY_TYPE_WILL_DELAY_INTERVAL ((uint8_t)24) |
| 36 |
#define AWS_MQTT5_PROPERTY_TYPE_REQUEST_RESPONSE_INFORMATION ((uint8_t)25) |
| 37 |
#define AWS_MQTT5_PROPERTY_TYPE_RESPONSE_INFORMATION ((uint8_t)26) |
| 38 |
#define AWS_MQTT5_PROPERTY_TYPE_SERVER_REFERENCE ((uint8_t)28) |
| 39 |
#define AWS_MQTT5_PROPERTY_TYPE_REASON_STRING ((uint8_t)31) |
| 40 |
#define AWS_MQTT5_PROPERTY_TYPE_RECEIVE_MAXIMUM ((uint8_t)33) |
| 41 |
#define AWS_MQTT5_PROPERTY_TYPE_TOPIC_ALIAS_MAXIMUM ((uint8_t)34) |
| 42 |
#define AWS_MQTT5_PROPERTY_TYPE_TOPIC_ALIAS ((uint8_t)35) |
| 43 |
#define AWS_MQTT5_PROPERTY_TYPE_MAXIMUM_QOS ((uint8_t)36) |
| 44 |
#define AWS_MQTT5_PROPERTY_TYPE_RETAIN_AVAILABLE ((uint8_t)37) |
| 45 |
#define AWS_MQTT5_PROPERTY_TYPE_USER_PROPERTY ((uint8_t)38) |
| 46 |
#define AWS_MQTT5_PROPERTY_TYPE_MAXIMUM_PACKET_SIZE ((uint8_t)39) |
| 47 |
#define AWS_MQTT5_PROPERTY_TYPE_WILDCARD_SUBSCRIPTIONS_AVAILABLE ((uint8_t)40) |
| 48 |
#define AWS_MQTT5_PROPERTY_TYPE_SUBSCRIPTION_IDENTIFIERS_AVAILABLE ((uint8_t)41) |
| 49 |
#define AWS_MQTT5_PROPERTY_TYPE_SHARED_SUBSCRIPTIONS_AVAILABLE ((uint8_t)42) |
| 50 |
|
| 51 |
|
| 52 |
#define AWS_MQTT5_CONNECT_FLAGS_WILL_BIT (1U << 2) |
| 53 |
#define AWS_MQTT5_CONNECT_FLAGS_CLEAN_START_BIT (1U << 1) |
| 54 |
#define AWS_MQTT5_CONNECT_FLAGS_USER_NAME_BIT (1U << 7) |
| 55 |
#define AWS_MQTT5_CONNECT_FLAGS_PASSWORD_BIT (1U << 6) |
| 56 |
#define AWS_MQTT5_CONNECT_FLAGS_WILL_RETAIN_BIT (1U << 5) |
| 57 |
|
| 58 |
#define AWS_MQTT5_CONNECT_FLAGS_WILL_QOS_BIT_POSITION 3 |
| 59 |
#define AWS_MQTT5_CONNECT_FLAGS_WILL_QOS_BIT_MASK 0x03 |
| 60 |
|
| 61 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_NO_LOCAL (1U << 2) |
| 62 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_RETAIN_AS_PUBLISHED (1U << 3) |
| 63 |
|
| 64 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_RETAIN_HANDLING_TYPE_BIT_POSITION 4 |
| 65 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_RETAIN_HANDLING_TYPE_BIT_MASK 0x03 |
| 66 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_QOS_BIT_POSITION 0 |
| 67 |
#define AWS_MQTT5_SUBSCRIBE_FLAGS_QOS_BIT_MASK 0x03 |
| 68 |
|
| 69 |
|
| 70 |
#define AWS_IOT_CORE_MAXIMUM_TOPIC_LENGTH 256 |
| 71 |
#define AWS_IOT_CORE_MAXIMUM_TOPIC_SEGMENTS 8 |
| 72 |
|
| 73 |
|
| 74 |
#define AWS_IOT_CORE_PUBLISH_PER_SECOND_LIMIT 100 |
| 75 |
#define AWS_IOT_CORE_THROUGHPUT_LIMIT (512 * 1024) |
| 76 |
|
| 77 |
|
| 78 |
#define AWS_MQTT5_DEFAULT_SOCKET_CONNECT_TIMEOUT_MS 10000 |
| 79 |
#define AWS_MQTT5_CLIENT_DEFAULT_MIN_RECONNECT_DELAY_MS 1000 |
| 80 |
#define AWS_MQTT5_CLIENT_DEFAULT_MAX_RECONNECT_DELAY_MS 120000 |
| 81 |
#define AWS_MQTT5_CLIENT_DEFAULT_MIN_CONNECTED_TIME_TO_RESET_RECONNECT_DELAY_MS 30000 |
| 82 |
#define AWS_MQTT5_CLIENT_DEFAULT_PING_TIMEOUT_MS 30000 |
| 83 |
#define AWS_MQTT5_CLIENT_DEFAULT_CONNACK_TIMEOUT_MS 20000 |
| 84 |
#define AWS_MQTT5_CLIENT_DEFAULT_OPERATION_TIMEOUNT_SECONDS 60 |
| 85 |
#define AWS_MQTT5_CLIENT_DEFAULT_INBOUND_TOPIC_ALIAS_CACHE_SIZE 25 |
| 86 |
#define AWS_MQTT5_CLIENT_DEFAULT_OUTBOUND_TOPIC_ALIAS_CACHE_SIZE 25 |
| 87 |
|
| 88 |
AWS_EXTERN_C_BEGIN |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
AWS_MQTT_API extern struct aws_byte_cursor g_aws_mqtt5_connect_protocol_cursor; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
AWS_MQTT_API uint8_t aws_mqtt5_compute_fixed_header_byte1(enum aws_mqtt5_packet_type packet_type, uint8_t flags); |
| 106 |
|
| 107 |
AWS_MQTT_API void aws_mqtt5_negotiated_settings_log( |
| 108 |
struct aws_mqtt5_negotiated_settings *negotiated_settings, |
| 109 |
enum aws_log_level level); |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
AWS_MQTT_API int aws_mqtt5_negotiated_settings_apply_client_id( |
| 118 |
struct aws_mqtt5_negotiated_settings *negotiated_settings, |
| 119 |
const struct aws_byte_cursor *client_id); |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
AWS_MQTT_API void aws_mqtt5_negotiated_settings_reset( |
| 130 |
struct aws_mqtt5_negotiated_settings *negotiated_settings, |
| 131 |
const struct aws_mqtt5_packet_connect_view *packet_connect_view); |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
AWS_MQTT_API void aws_mqtt5_negotiated_settings_apply_connack( |
| 141 |
struct aws_mqtt5_negotiated_settings *negotiated_settings, |
| 142 |
const struct aws_mqtt5_packet_connack_view *connack_data); |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
AWS_MQTT_API const char *aws_mqtt5_disconnect_reason_code_to_c_string( |
| 151 |
enum aws_mqtt5_disconnect_reason_code reason_code, |
| 152 |
bool *is_valid); |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
AWS_MQTT_API const char *aws_mqtt5_connect_reason_code_to_c_string(enum aws_mqtt5_connect_reason_code reason_code); |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
AWS_MQTT_API const char *aws_mqtt5_puback_reason_code_to_c_string(enum aws_mqtt5_puback_reason_code reason_code); |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
AWS_MQTT_API const char *aws_mqtt5_suback_reason_code_to_c_string(enum aws_mqtt5_suback_reason_code reason_code); |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
AWS_MQTT_API const char *aws_mqtt5_unsuback_reason_code_to_c_string(enum aws_mqtt5_unsuback_reason_code reason_code); |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
AWS_MQTT_API const char *aws_mqtt5_client_session_behavior_type_to_c_string( |
| 193 |
enum aws_mqtt5_client_session_behavior_type session_behavior); |
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
AWS_MQTT_API enum aws_mqtt5_client_session_behavior_type aws_mqtt5_client_session_behavior_type_to_non_default( |
| 202 |
enum aws_mqtt5_client_session_behavior_type session_behavior); |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
AWS_MQTT_API const char *aws_mqtt5_outbound_topic_alias_behavior_type_to_c_string( |
| 211 |
enum aws_mqtt5_client_outbound_topic_alias_behavior_type outbound_aliasing_behavior); |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
AWS_MQTT_API bool aws_mqtt5_outbound_topic_alias_behavior_type_validate( |
| 220 |
enum aws_mqtt5_client_outbound_topic_alias_behavior_type outbound_aliasing_behavior); |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
AWS_MQTT_API enum aws_mqtt5_client_outbound_topic_alias_behavior_type |
| 229 |
aws_mqtt5_outbound_topic_alias_behavior_type_to_non_default( |
| 230 |
enum aws_mqtt5_client_outbound_topic_alias_behavior_type outbound_aliasing_behavior); |
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
AWS_MQTT_API const char *aws_mqtt5_inbound_topic_alias_behavior_type_to_c_string( |
| 239 |
enum aws_mqtt5_client_inbound_topic_alias_behavior_type inbound_aliasing_behavior); |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
AWS_MQTT_API bool aws_mqtt5_inbound_topic_alias_behavior_type_validate( |
| 248 |
enum aws_mqtt5_client_inbound_topic_alias_behavior_type inbound_aliasing_behavior); |
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
AWS_MQTT_API enum aws_mqtt5_client_inbound_topic_alias_behavior_type |
| 257 |
aws_mqtt5_inbound_topic_alias_behavior_type_to_non_default( |
| 258 |
enum aws_mqtt5_client_inbound_topic_alias_behavior_type inbound_aliasing_behavior); |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
AWS_MQTT_API const char *aws_mqtt5_extended_validation_and_flow_control_options_to_c_string( |
| 267 |
enum aws_mqtt5_extended_validation_and_flow_control_options extended_validation_behavior); |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
AWS_MQTT_API const char *aws_mqtt5_client_operation_queue_behavior_type_to_c_string( |
| 276 |
enum aws_mqtt5_client_operation_queue_behavior_type offline_queue_behavior); |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
AWS_MQTT_API enum aws_mqtt5_client_operation_queue_behavior_type |
| 285 |
aws_mqtt5_client_operation_queue_behavior_type_to_non_default( |
| 286 |
enum aws_mqtt5_client_operation_queue_behavior_type offline_queue_behavior); |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
AWS_MQTT_API const char *aws_mqtt5_client_lifecycle_event_type_to_c_string( |
| 295 |
enum aws_mqtt5_client_lifecycle_event_type lifecycle_event); |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
AWS_MQTT_API const char *aws_mqtt5_payload_format_indicator_to_c_string( |
| 304 |
enum aws_mqtt5_payload_format_indicator format_indicator); |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
AWS_MQTT_API const char *aws_mqtt5_retain_handling_type_to_c_string( |
| 313 |
enum aws_mqtt5_retain_handling_type retain_handling_type); |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
AWS_MQTT_API const char *aws_mqtt5_packet_type_to_c_string(enum aws_mqtt5_packet_type packet_type); |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
AWS_MQTT_API uint64_t aws_mqtt5_client_random_in_range(uint64_t from, uint64_t to); |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
AWS_MQTT_API struct aws_byte_cursor aws_mqtt5_topic_skip_aws_iot_core_uncounted_prefix( |
| 340 |
struct aws_byte_cursor topic_cursor); |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
AWS_MQTT_API size_t aws_mqtt5_topic_get_segment_count(struct aws_byte_cursor topic_cursor); |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
AWS_MQTT_API bool aws_mqtt_is_valid_topic_filter_for_iot_core(struct aws_byte_cursor topic_filter_cursor); |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
AWS_MQTT_API bool aws_mqtt_is_valid_topic_for_iot_core(struct aws_byte_cursor topic_cursor); |
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
AWS_MQTT_API bool aws_mqtt_is_topic_filter_shared_subscription(struct aws_byte_cursor topic_cursor); |
| 369 |
|
| 370 |
AWS_EXTERN_C_END |
| 371 |
|
| 372 |
#endif |