| 1 |
#ifndef AWS_MQTT_MQTT5_OPERATION_H |
| 2 |
#define AWS_MQTT_MQTT5_OPERATION_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/mqtt/mqtt.h> |
| 10 |
|
| 11 |
#include <aws/common/linked_list.h> |
| 12 |
#include <aws/common/logging.h> |
| 13 |
#include <aws/common/ref_count.h> |
| 14 |
#include <aws/http/proxy.h> |
| 15 |
#include <aws/io/host_resolver.h> |
| 16 |
#include <aws/io/retry_strategy.h> |
| 17 |
#include <aws/io/socket.h> |
| 18 |
#include <aws/io/tls_channel_handler.h> |
| 19 |
#include <aws/mqtt/v5/mqtt5_client.h> |
| 20 |
#include <aws/mqtt/v5/mqtt5_packet_storage.h> |
| 21 |
#include <aws/mqtt/v5/mqtt5_types.h> |
| 22 |
|
| 23 |
struct aws_client_bootstrap; |
| 24 |
struct aws_mqtt5_client; |
| 25 |
struct aws_mqtt5_operation; |
| 26 |
struct aws_string; |
| 27 |
|
| 28 |
|
| 29 |
struct aws_mqtt5_operation_vtable { |
| 30 |
void (*aws_mqtt5_operation_completion_fn)( |
| 31 |
struct aws_mqtt5_operation *operation, |
| 32 |
int error_code, |
| 33 |
enum aws_mqtt5_packet_type packet_type, |
| 34 |
const void *completion_view); |
| 35 |
|
| 36 |
void ( |
| 37 |
*aws_mqtt5_operation_set_packet_id_fn)(struct aws_mqtt5_operation *operation, aws_mqtt5_packet_id_t packet_id); |
| 38 |
|
| 39 |
aws_mqtt5_packet_id_t *(*aws_mqtt5_operation_get_packet_id_address_fn)(const struct aws_mqtt5_operation *operation); |
| 40 |
|
| 41 |
int (*aws_mqtt5_operation_validate_vs_connection_settings_fn)( |
| 42 |
const void *operation_packet_view, |
| 43 |
const struct aws_mqtt5_client *client); |
| 44 |
|
| 45 |
uint32_t (*aws_mqtt5_operation_get_ack_timeout_override_fn)(const struct aws_mqtt5_operation *operation); |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
enum aws_mqtt5_operation_statistic_state_flags { |
| 50 |
|
| 51 |
AWS_MQTT5_OSS_NONE = 0, |
| 52 |
|
| 53 |
|
| 54 |
AWS_MQTT5_OSS_INCOMPLETE = 1 << 0, |
| 55 |
|
| 56 |
|
| 57 |
AWS_MQTT5_OSS_UNACKED = 1 << 1, |
| 58 |
}; |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
struct aws_mqtt5_operation { |
| 65 |
const struct aws_mqtt5_operation_vtable *vtable; |
| 66 |
struct aws_ref_count ref_count; |
| 67 |
uint64_t ack_timeout_timepoint_ns; |
| 68 |
struct aws_priority_queue_node priority_queue_node; |
| 69 |
struct aws_linked_list_node node; |
| 70 |
|
| 71 |
enum aws_mqtt5_packet_type packet_type; |
| 72 |
const void *packet_view; |
| 73 |
|
| 74 |
|
| 75 |
enum aws_mqtt5_operation_statistic_state_flags statistic_state_flags; |
| 76 |
|
| 77 |
|
| 78 |
size_t packet_size; |
| 79 |
|
| 80 |
void *impl; |
| 81 |
}; |
| 82 |
|
| 83 |
struct aws_mqtt5_operation_connect { |
| 84 |
struct aws_mqtt5_operation base; |
| 85 |
struct aws_allocator *allocator; |
| 86 |
|
| 87 |
struct aws_mqtt5_packet_connect_storage options_storage; |
| 88 |
}; |
| 89 |
|
| 90 |
struct aws_mqtt5_operation_publish { |
| 91 |
struct aws_mqtt5_operation base; |
| 92 |
struct aws_allocator *allocator; |
| 93 |
|
| 94 |
struct aws_mqtt5_packet_publish_storage options_storage; |
| 95 |
|
| 96 |
struct aws_mqtt5_publish_completion_options completion_options; |
| 97 |
}; |
| 98 |
|
| 99 |
struct aws_mqtt5_operation_puback { |
| 100 |
struct aws_mqtt5_operation base; |
| 101 |
struct aws_allocator *allocator; |
| 102 |
|
| 103 |
struct aws_mqtt5_packet_puback_storage options_storage; |
| 104 |
|
| 105 |
struct aws_mqtt5_manual_publish_acknowledgement_completion_options completion_options; |
| 106 |
}; |
| 107 |
|
| 108 |
struct aws_mqtt5_operation_disconnect { |
| 109 |
struct aws_mqtt5_operation base; |
| 110 |
struct aws_allocator *allocator; |
| 111 |
|
| 112 |
struct aws_mqtt5_packet_disconnect_storage options_storage; |
| 113 |
|
| 114 |
struct aws_mqtt5_disconnect_completion_options external_completion_options; |
| 115 |
struct aws_mqtt5_disconnect_completion_options internal_completion_options; |
| 116 |
}; |
| 117 |
|
| 118 |
struct aws_mqtt5_operation_subscribe { |
| 119 |
struct aws_mqtt5_operation base; |
| 120 |
struct aws_allocator *allocator; |
| 121 |
|
| 122 |
struct aws_mqtt5_packet_subscribe_storage options_storage; |
| 123 |
|
| 124 |
struct aws_mqtt5_subscribe_completion_options completion_options; |
| 125 |
}; |
| 126 |
|
| 127 |
struct aws_mqtt5_operation_unsubscribe { |
| 128 |
struct aws_mqtt5_operation base; |
| 129 |
struct aws_allocator *allocator; |
| 130 |
|
| 131 |
struct aws_mqtt5_packet_unsubscribe_storage options_storage; |
| 132 |
|
| 133 |
struct aws_mqtt5_unsubscribe_completion_options completion_options; |
| 134 |
}; |
| 135 |
|
| 136 |
struct aws_mqtt5_operation_pingreq { |
| 137 |
struct aws_mqtt5_operation base; |
| 138 |
struct aws_allocator *allocator; |
| 139 |
}; |
| 140 |
|
| 141 |
struct aws_mqtt5_client_options_storage { |
| 142 |
struct aws_allocator *allocator; |
| 143 |
|
| 144 |
struct aws_string *host_name; |
| 145 |
uint32_t port; |
| 146 |
struct aws_client_bootstrap *bootstrap; |
| 147 |
struct aws_socket_options socket_options; |
| 148 |
|
| 149 |
struct aws_tls_connection_options tls_options; |
| 150 |
struct aws_tls_connection_options *tls_options_ptr; |
| 151 |
|
| 152 |
struct aws_http_proxy_options http_proxy_options; |
| 153 |
struct aws_http_proxy_config *http_proxy_config; |
| 154 |
|
| 155 |
aws_mqtt5_transform_websocket_handshake_fn *websocket_handshake_transform; |
| 156 |
void *websocket_handshake_transform_user_data; |
| 157 |
|
| 158 |
aws_mqtt5_publish_received_fn *publish_received_handler; |
| 159 |
void *publish_received_handler_user_data; |
| 160 |
|
| 161 |
enum aws_mqtt5_client_session_behavior_type session_behavior; |
| 162 |
enum aws_mqtt5_extended_validation_and_flow_control_options extended_validation_and_flow_control_options; |
| 163 |
enum aws_mqtt5_client_operation_queue_behavior_type offline_queue_behavior; |
| 164 |
|
| 165 |
enum aws_exponential_backoff_jitter_mode retry_jitter_mode; |
| 166 |
uint64_t min_reconnect_delay_ms; |
| 167 |
uint64_t max_reconnect_delay_ms; |
| 168 |
uint64_t min_connected_time_to_reset_reconnect_delay_ms; |
| 169 |
|
| 170 |
uint32_t ack_timeout_seconds; |
| 171 |
|
| 172 |
uint32_t ping_timeout_ms; |
| 173 |
uint32_t connack_timeout_ms; |
| 174 |
|
| 175 |
struct aws_mqtt5_client_topic_alias_options topic_aliasing_options; |
| 176 |
|
| 177 |
struct aws_mqtt5_packet_connect_storage *connect; |
| 178 |
|
| 179 |
aws_mqtt5_client_connection_event_callback_fn *lifecycle_event_handler; |
| 180 |
void *lifecycle_event_handler_user_data; |
| 181 |
|
| 182 |
aws_mqtt5_client_termination_completion_fn *client_termination_handler; |
| 183 |
void *client_termination_handler_user_data; |
| 184 |
|
| 185 |
struct aws_host_resolution_config host_resolution_override; |
| 186 |
|
| 187 |
struct aws_mqtt_iot_metrics_storage *metrics_storage; |
| 188 |
}; |
| 189 |
|
| 190 |
AWS_EXTERN_C_BEGIN |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
AWS_MQTT_API struct aws_mqtt5_operation *aws_mqtt5_operation_acquire(struct aws_mqtt5_operation *operation); |
| 195 |
|
| 196 |
AWS_MQTT_API struct aws_mqtt5_operation *aws_mqtt5_operation_release(struct aws_mqtt5_operation *operation); |
| 197 |
|
| 198 |
AWS_MQTT_API void aws_mqtt5_operation_complete( |
| 199 |
struct aws_mqtt5_operation *operation, |
| 200 |
int error_code, |
| 201 |
enum aws_mqtt5_packet_type packet_type, |
| 202 |
const void *associated_view); |
| 203 |
|
| 204 |
AWS_MQTT_API void aws_mqtt5_operation_set_packet_id( |
| 205 |
struct aws_mqtt5_operation *operation, |
| 206 |
aws_mqtt5_packet_id_t packet_id); |
| 207 |
|
| 208 |
AWS_MQTT_API aws_mqtt5_packet_id_t aws_mqtt5_operation_get_packet_id(const struct aws_mqtt5_operation *operation); |
| 209 |
|
| 210 |
AWS_MQTT_API aws_mqtt5_packet_id_t *aws_mqtt5_operation_get_packet_id_address( |
| 211 |
const struct aws_mqtt5_operation *operation); |
| 212 |
|
| 213 |
AWS_MQTT_API int aws_mqtt5_operation_validate_vs_connection_settings( |
| 214 |
const struct aws_mqtt5_operation *operation, |
| 215 |
const struct aws_mqtt5_client *client); |
| 216 |
|
| 217 |
AWS_MQTT_API uint32_t aws_mqtt5_operation_get_ack_timeout_override(const struct aws_mqtt5_operation *operation); |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
AWS_MQTT_API struct aws_mqtt5_operation_connect *aws_mqtt5_operation_connect_new( |
| 222 |
struct aws_allocator *allocator, |
| 223 |
const struct aws_mqtt5_packet_connect_view *connect_options, |
| 224 |
const struct aws_mqtt5_client_options_storage *option_storage); |
| 225 |
|
| 226 |
AWS_MQTT_API int aws_mqtt5_packet_connect_view_validate(const struct aws_mqtt5_packet_connect_view *connect_view); |
| 227 |
|
| 228 |
AWS_MQTT_API void aws_mqtt5_packet_connect_view_log( |
| 229 |
const struct aws_mqtt5_packet_connect_view *connect_view, |
| 230 |
enum aws_log_level level); |
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
AWS_MQTT_API void aws_mqtt5_packet_connack_view_log( |
| 235 |
const struct aws_mqtt5_packet_connack_view *connack_view, |
| 236 |
enum aws_log_level level); |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
AWS_MQTT_API struct aws_mqtt5_operation_disconnect *aws_mqtt5_operation_disconnect_new( |
| 241 |
struct aws_allocator *allocator, |
| 242 |
const struct aws_mqtt5_packet_disconnect_view *disconnect_options, |
| 243 |
const struct aws_mqtt5_disconnect_completion_options *external_completion_options, |
| 244 |
const struct aws_mqtt5_disconnect_completion_options *internal_completion_options); |
| 245 |
|
| 246 |
AWS_MQTT_API struct aws_mqtt5_operation_disconnect *aws_mqtt5_operation_disconnect_acquire( |
| 247 |
struct aws_mqtt5_operation_disconnect *disconnect_op); |
| 248 |
|
| 249 |
AWS_MQTT_API struct aws_mqtt5_operation_disconnect *aws_mqtt5_operation_disconnect_release( |
| 250 |
struct aws_mqtt5_operation_disconnect *disconnect_op); |
| 251 |
|
| 252 |
AWS_MQTT_API int aws_mqtt5_packet_disconnect_view_validate( |
| 253 |
const struct aws_mqtt5_packet_disconnect_view *disconnect_view); |
| 254 |
|
| 255 |
AWS_MQTT_API void aws_mqtt5_packet_disconnect_view_log( |
| 256 |
const struct aws_mqtt5_packet_disconnect_view *disconnect_view, |
| 257 |
enum aws_log_level level); |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
AWS_MQTT_API struct aws_mqtt5_operation_publish *aws_mqtt5_operation_publish_new( |
| 262 |
struct aws_allocator *allocator, |
| 263 |
const struct aws_mqtt5_client *client, |
| 264 |
const struct aws_mqtt5_packet_publish_view *publish_options, |
| 265 |
const struct aws_mqtt5_publish_completion_options *completion_options); |
| 266 |
|
| 267 |
AWS_MQTT_API int aws_mqtt5_packet_publish_view_validate(const struct aws_mqtt5_packet_publish_view *publish_view); |
| 268 |
|
| 269 |
AWS_MQTT_API void aws_mqtt5_packet_publish_view_log( |
| 270 |
const struct aws_mqtt5_packet_publish_view *publish_view, |
| 271 |
enum aws_log_level level); |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
AWS_MQTT_API struct aws_mqtt5_operation_puback *aws_mqtt5_operation_puback_new( |
| 276 |
struct aws_allocator *allocator, |
| 277 |
const struct aws_mqtt5_packet_puback_view *puback_options, |
| 278 |
const struct aws_mqtt5_manual_publish_acknowledgement_completion_options *completion_options); |
| 279 |
|
| 280 |
AWS_MQTT_API void aws_mqtt5_packet_puback_view_log( |
| 281 |
const struct aws_mqtt5_packet_puback_view *puback_view, |
| 282 |
enum aws_log_level level); |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
AWS_MQTT_API struct aws_mqtt5_operation_subscribe *aws_mqtt5_operation_subscribe_new( |
| 287 |
struct aws_allocator *allocator, |
| 288 |
const struct aws_mqtt5_client *client, |
| 289 |
const struct aws_mqtt5_packet_subscribe_view *subscribe_options, |
| 290 |
const struct aws_mqtt5_subscribe_completion_options *completion_options); |
| 291 |
|
| 292 |
AWS_MQTT_API int aws_mqtt5_packet_subscribe_view_validate(const struct aws_mqtt5_packet_subscribe_view *subscribe_view); |
| 293 |
|
| 294 |
AWS_MQTT_API void aws_mqtt5_packet_subscribe_view_log( |
| 295 |
const struct aws_mqtt5_packet_subscribe_view *subscribe_view, |
| 296 |
enum aws_log_level level); |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
AWS_MQTT_API void aws_mqtt5_packet_suback_view_log( |
| 301 |
const struct aws_mqtt5_packet_suback_view *suback_view, |
| 302 |
enum aws_log_level level); |
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
AWS_MQTT_API struct aws_mqtt5_operation_unsubscribe *aws_mqtt5_operation_unsubscribe_new( |
| 307 |
struct aws_allocator *allocator, |
| 308 |
const struct aws_mqtt5_client *client, |
| 309 |
const struct aws_mqtt5_packet_unsubscribe_view *unsubscribe_options, |
| 310 |
const struct aws_mqtt5_unsubscribe_completion_options *completion_options); |
| 311 |
|
| 312 |
AWS_MQTT_API int aws_mqtt5_packet_unsubscribe_view_validate( |
| 313 |
const struct aws_mqtt5_packet_unsubscribe_view *unsubscribe_view); |
| 314 |
|
| 315 |
AWS_MQTT_API void aws_mqtt5_packet_unsubscribe_view_log( |
| 316 |
const struct aws_mqtt5_packet_unsubscribe_view *unsubscribe_view, |
| 317 |
enum aws_log_level level); |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
AWS_MQTT_API void aws_mqtt5_packet_unsuback_view_log( |
| 322 |
const struct aws_mqtt5_packet_unsuback_view *unsuback_view, |
| 323 |
enum aws_log_level level); |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
AWS_MQTT_API struct aws_mqtt5_operation_pingreq *aws_mqtt5_operation_pingreq_new(struct aws_allocator *allocator); |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
AWS_MQTT_API |
| 332 |
struct aws_mqtt5_client_options_storage *aws_mqtt5_client_options_storage_new( |
| 333 |
struct aws_allocator *allocator, |
| 334 |
const struct aws_mqtt5_client_options *options); |
| 335 |
|
| 336 |
AWS_MQTT_API |
| 337 |
void aws_mqtt5_client_options_storage_destroy(struct aws_mqtt5_client_options_storage *options_storage); |
| 338 |
|
| 339 |
AWS_MQTT_API int aws_mqtt5_client_options_validate(const struct aws_mqtt5_client_options *client_options); |
| 340 |
|
| 341 |
AWS_MQTT_API void aws_mqtt5_client_options_storage_log( |
| 342 |
const struct aws_mqtt5_client_options_storage *options_storage, |
| 343 |
enum aws_log_level level); |
| 344 |
|
| 345 |
AWS_EXTERN_C_END |
| 346 |
|
| 347 |
#endif |