Debian Codegraph @

crt/aws-c-mqtt/include/aws/mqtt/private/client_impl_shared.h

raw symbols SCIP
1 #ifndef AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H
2 #define AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8
9 #include <aws/mqtt/client.h>
10
11 struct aws_mqtt_client_connection;
12
13 /*
14 * Internal enum that indicates what type of struct the underlying impl pointer actually is. We use this
15 * to safely interact with private APIs on the implementation or extract the adapted 5 client directly, as
16 * necessary.
17 */
18 enum aws_mqtt311_impl_type {
19
20 /* 311 connection impl can be cast to `struct aws_mqtt_client_connection_311_impl` */
21 AWS_MQTT311_IT_311_CONNECTION,
22
23 /* 311 connection impl can be cast to `struct aws_mqtt_client_connection_5_impl`*/
24 AWS_MQTT311_IT_5_ADAPTER,
25 };
26
27 struct aws_mqtt_client_connection_vtable {
28
29 struct aws_mqtt_client_connection *(*acquire_fn)(void *impl);
30
31 void (*release_fn)(void *impl);
32
33 int (*set_will_fn)(
34 void *impl,
35 const struct aws_byte_cursor *topic,
36 enum aws_mqtt_qos qos,
37 bool retain,
38 const struct aws_byte_cursor *payload);
39
40 int (*set_login_fn)(void *impl, const struct aws_byte_cursor *username, const struct aws_byte_cursor *password);
41
42 int (*use_websockets_fn)(
43 void *impl,
44 aws_mqtt_transform_websocket_handshake_fn *transformer,
45 void *transformer_ud,
46 aws_mqtt_validate_websocket_handshake_fn *validator,
47 void *validator_ud);
48
49 int (*set_http_proxy_options_fn)(void *impl, struct aws_http_proxy_options *proxy_options);
50
51 int (*set_host_resolution_options_fn)(void *impl, const struct aws_host_resolution_config *host_resolution_config);
52
53 int (*set_reconnect_timeout_fn)(void *impl, uint64_t min_timeout, uint64_t max_timeout);
54
55 int (*set_connection_interruption_handlers_fn)(
56 void *impl,
57 aws_mqtt_client_on_connection_interrupted_fn *on_interrupted,
58 void *on_interrupted_ud,
59 aws_mqtt_client_on_connection_resumed_fn *on_resumed,
60 void *on_resumed_ud);
61
62 int (*set_connection_result_handlers)(
63 void *impl,
64 aws_mqtt_client_on_connection_success_fn *on_connection_success,
65 void *on_connection_success_ud,
66 aws_mqtt_client_on_connection_failure_fn *on_connection_failure,
67 void *on_connection_failure_ud);
68
69 int (*set_connection_closed_handler_fn)(
70 void *impl,
71 aws_mqtt_client_on_connection_closed_fn *on_closed,
72 void *on_closed_ud);
73
74 int (*set_on_any_publish_handler_fn)(
75 void *impl,
76 aws_mqtt_client_publish_received_fn *on_any_publish,
77 void *on_any_publish_ud);
78
79 int (*set_connection_termination_handler_fn)(
80 void *impl,
81 aws_mqtt_client_on_connection_termination_fn *on_termination,
82 void *on_termination_ud);
83
84 int (*connect_fn)(void *impl, const struct aws_mqtt_connection_options *connection_options);
85
86 int (*reconnect_fn)(void *impl, aws_mqtt_client_on_connection_complete_fn *on_connection_complete, void *userdata);
87
88 int (*disconnect_fn)(void *impl, aws_mqtt_client_on_disconnect_fn *on_disconnect, void *userdata);
89
90 uint16_t (*subscribe_multiple_fn)(
91 void *impl,
92 const struct aws_array_list *topic_filters,
93 aws_mqtt_suback_multi_fn *on_suback,
94 void *on_suback_ud);
95
96 uint16_t (*subscribe_fn)(
97 void *impl,
98 const struct aws_byte_cursor *topic_filter,
99 enum aws_mqtt_qos qos,
100 aws_mqtt_client_publish_received_fn *on_publish,
101 void *on_publish_ud,
102 aws_mqtt_userdata_cleanup_fn *on_ud_cleanup,
103 aws_mqtt_suback_fn *on_suback,
104 void *on_suback_ud);
105
106 uint16_t (*resubscribe_existing_topics_fn)(void *impl, aws_mqtt_suback_multi_fn *on_suback, void *on_suback_ud);
107
108 uint16_t (*unsubscribe_fn)(
109 void *impl,
110 const struct aws_byte_cursor *topic_filter,
111 aws_mqtt_op_complete_fn *on_unsuback,
112 void *on_unsuback_ud);
113
114 uint16_t (*publish_fn)(
115 void *impl,
116 const struct aws_byte_cursor *topic,
117 enum aws_mqtt_qos qos,
118 bool retain,
119 const struct aws_byte_cursor *payload,
120 aws_mqtt_op_complete_fn *on_complete,
121 void *userdata);
122
123 int (*get_stats_fn)(void *impl, struct aws_mqtt_connection_operation_statistics *stats);
124
125 int (*set_metrics_fn)(void *impl, const struct aws_mqtt_iot_metrics *metrics);
126
127 enum aws_mqtt311_impl_type (*get_impl_type)(const void *impl);
128
129 struct aws_event_loop *(*get_event_loop)(const void *impl);
130 };
131
132 struct aws_mqtt_client_connection {
133 struct aws_mqtt_client_connection_vtable *vtable;
134 void *impl;
135 };
136
137 AWS_MQTT_API enum aws_mqtt311_impl_type aws_mqtt_client_connection_get_impl_type(
138 const struct aws_mqtt_client_connection *connection);
139
140 AWS_MQTT_API uint64_t aws_mqtt_hash_uint16_t(const void *item);
141
142 AWS_MQTT_API bool aws_mqtt_compare_uint16_t_eq(const void *a, const void *b);
143
144 AWS_MQTT_API uint64_t aws_mqtt_hash_uint64_t(const void *item);
145
146 AWS_MQTT_API bool aws_mqtt_compare_uint64_t_eq(const void *a, const void *b);
147
148 AWS_MQTT_API bool aws_mqtt_byte_cursor_hash_equality(const void *a, const void *b);
149
150 AWS_MQTT_API struct aws_event_loop *aws_mqtt_client_connection_get_event_loop(
151 const struct aws_mqtt_client_connection *connection);
152
153 #endif /* AWS_MQTT_PRIVATE_CLIENT_IMPL_SHARED_H */