| 1 |
#ifndef AWS_MQTT_PRIVATE_PACKETS_H |
| 2 |
#define AWS_MQTT_PRIVATE_PACKETS_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/mqtt/mqtt.h> |
| 10 |
#include <aws/mqtt/private/fixed_header.h> |
| 11 |
|
| 12 |
#include <aws/common/array_list.h> |
| 13 |
#include <aws/common/byte_buf.h> |
| 14 |
#include <aws/common/string.h> |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
struct aws_mqtt_subscription { |
| 25 |
|
| 26 |
struct aws_byte_cursor topic_filter; |
| 27 |
|
| 28 |
enum aws_mqtt_qos qos; |
| 29 |
}; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
struct aws_mqtt_packet_ack { |
| 40 |
|
| 41 |
struct aws_mqtt_fixed_header fixed_header; |
| 42 |
|
| 43 |
|
| 44 |
uint16_t packet_identifier; |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
struct aws_mqtt_packet_suback { |
| 51 |
|
| 52 |
struct aws_mqtt_fixed_header fixed_header; |
| 53 |
|
| 54 |
|
| 55 |
uint16_t packet_identifier; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
struct aws_array_list return_codes; |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
struct aws_mqtt_packet_connect { |
| 64 |
|
| 65 |
struct aws_mqtt_fixed_header fixed_header; |
| 66 |
|
| 67 |
|
| 68 |
bool clean_session; |
| 69 |
bool has_will; |
| 70 |
bool will_retain; |
| 71 |
bool has_password; |
| 72 |
bool has_username; |
| 73 |
uint16_t keep_alive_timeout; |
| 74 |
enum aws_mqtt_qos will_qos; |
| 75 |
struct aws_byte_cursor client_identifier; |
| 76 |
|
| 77 |
|
| 78 |
struct aws_byte_cursor will_topic; |
| 79 |
struct aws_byte_cursor will_message; |
| 80 |
struct aws_byte_cursor username; |
| 81 |
struct aws_byte_cursor password; |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
struct aws_mqtt_packet_connack { |
| 86 |
|
| 87 |
struct aws_mqtt_fixed_header fixed_header; |
| 88 |
|
| 89 |
|
| 90 |
bool session_present; |
| 91 |
uint8_t connect_return_code; |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
struct aws_mqtt_packet_publish { |
| 96 |
struct aws_mqtt_fixed_header fixed_header; |
| 97 |
|
| 98 |
|
| 99 |
uint16_t packet_identifier; |
| 100 |
struct aws_byte_cursor topic_name; |
| 101 |
|
| 102 |
|
| 103 |
struct aws_byte_cursor payload; |
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
struct aws_mqtt_packet_subscribe { |
| 108 |
|
| 109 |
struct aws_mqtt_fixed_header fixed_header; |
| 110 |
|
| 111 |
|
| 112 |
uint16_t packet_identifier; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
struct aws_array_list topic_filters; |
| 117 |
}; |
| 118 |
|
| 119 |
|
| 120 |
struct aws_mqtt_packet_unsubscribe { |
| 121 |
|
| 122 |
struct aws_mqtt_fixed_header fixed_header; |
| 123 |
|
| 124 |
|
| 125 |
uint16_t packet_identifier; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
struct aws_array_list topic_filters; |
| 130 |
}; |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
struct aws_mqtt_packet_connection { |
| 138 |
|
| 139 |
struct aws_mqtt_fixed_header fixed_header; |
| 140 |
}; |
| 141 |
|
| 142 |
#ifdef __cplusplus |
| 143 |
extern "C" { |
| 144 |
#endif |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
AWS_MQTT_API |
| 150 |
int aws_mqtt_packet_ack_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_ack *packet); |
| 151 |
|
| 152 |
AWS_MQTT_API |
| 153 |
int aws_mqtt_packet_ack_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_ack *packet); |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
AWS_MQTT_API |
| 159 |
int aws_mqtt_packet_connect_init( |
| 160 |
struct aws_mqtt_packet_connect *packet, |
| 161 |
struct aws_byte_cursor client_identifier, |
| 162 |
bool clean_session, |
| 163 |
uint16_t keep_alive); |
| 164 |
|
| 165 |
AWS_MQTT_API |
| 166 |
int aws_mqtt_packet_connect_add_will( |
| 167 |
struct aws_mqtt_packet_connect *packet, |
| 168 |
struct aws_byte_cursor topic, |
| 169 |
enum aws_mqtt_qos qos, |
| 170 |
bool retain, |
| 171 |
struct aws_byte_cursor payload); |
| 172 |
|
| 173 |
AWS_MQTT_API |
| 174 |
int aws_mqtt_packet_connect_add_credentials( |
| 175 |
struct aws_mqtt_packet_connect *packet, |
| 176 |
struct aws_byte_cursor username, |
| 177 |
struct aws_byte_cursor password); |
| 178 |
|
| 179 |
AWS_MQTT_API |
| 180 |
int aws_mqtt_packet_connect_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_connect *packet); |
| 181 |
|
| 182 |
AWS_MQTT_API |
| 183 |
int aws_mqtt_packet_connect_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_connect *packet); |
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
AWS_MQTT_API |
| 189 |
int aws_mqtt_packet_connack_init( |
| 190 |
struct aws_mqtt_packet_connack *packet, |
| 191 |
bool session_present, |
| 192 |
enum aws_mqtt_connect_return_code return_code); |
| 193 |
|
| 194 |
AWS_MQTT_API |
| 195 |
int aws_mqtt_packet_connack_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_connack *packet); |
| 196 |
|
| 197 |
AWS_MQTT_API |
| 198 |
int aws_mqtt_packet_connack_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_connack *packet); |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
AWS_MQTT_API |
| 204 |
int aws_mqtt_packet_publish_init( |
| 205 |
struct aws_mqtt_packet_publish *packet, |
| 206 |
bool retain, |
| 207 |
enum aws_mqtt_qos qos, |
| 208 |
bool dup, |
| 209 |
struct aws_byte_cursor topic_name, |
| 210 |
uint16_t packet_identifier, |
| 211 |
struct aws_byte_cursor payload); |
| 212 |
|
| 213 |
AWS_MQTT_API |
| 214 |
int aws_mqtt_packet_publish_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_publish *packet); |
| 215 |
|
| 216 |
AWS_MQTT_API |
| 217 |
int aws_mqtt_packet_publish_encode_headers(struct aws_byte_buf *buf, const struct aws_mqtt_packet_publish *packet); |
| 218 |
|
| 219 |
AWS_MQTT_API |
| 220 |
int aws_mqtt_packet_publish_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_publish *packet); |
| 221 |
|
| 222 |
AWS_MQTT_API |
| 223 |
void aws_mqtt_packet_publish_set_dup(struct aws_mqtt_packet_publish *packet); |
| 224 |
|
| 225 |
AWS_MQTT_API |
| 226 |
bool aws_mqtt_packet_publish_get_dup(const struct aws_mqtt_packet_publish *packet); |
| 227 |
|
| 228 |
AWS_MQTT_API |
| 229 |
enum aws_mqtt_qos aws_mqtt_packet_publish_get_qos(const struct aws_mqtt_packet_publish *packet); |
| 230 |
|
| 231 |
AWS_MQTT_API |
| 232 |
bool aws_mqtt_packet_publish_get_retain(const struct aws_mqtt_packet_publish *packet); |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
AWS_MQTT_API |
| 238 |
int aws_mqtt_packet_puback_init(struct aws_mqtt_packet_ack *packet, uint16_t packet_identifier); |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
AWS_MQTT_API |
| 244 |
int aws_mqtt_packet_pubrec_init(struct aws_mqtt_packet_ack *packet, uint16_t packet_identifier); |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
AWS_MQTT_API |
| 250 |
int aws_mqtt_packet_pubrel_init(struct aws_mqtt_packet_ack *packet, uint16_t packet_identifier); |
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
AWS_MQTT_API |
| 256 |
int aws_mqtt_packet_pubcomp_init(struct aws_mqtt_packet_ack *packet, uint16_t packet_identifier); |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
AWS_MQTT_API |
| 262 |
int aws_mqtt_packet_subscribe_init( |
| 263 |
struct aws_mqtt_packet_subscribe *packet, |
| 264 |
struct aws_allocator *allocator, |
| 265 |
uint16_t packet_identifier); |
| 266 |
|
| 267 |
AWS_MQTT_API |
| 268 |
void aws_mqtt_packet_subscribe_clean_up(struct aws_mqtt_packet_subscribe *packet); |
| 269 |
|
| 270 |
AWS_MQTT_API |
| 271 |
int aws_mqtt_packet_subscribe_add_topic( |
| 272 |
struct aws_mqtt_packet_subscribe *packet, |
| 273 |
struct aws_byte_cursor topic_filter, |
| 274 |
enum aws_mqtt_qos qos); |
| 275 |
|
| 276 |
AWS_MQTT_API |
| 277 |
int aws_mqtt_packet_subscribe_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_subscribe *packet); |
| 278 |
|
| 279 |
AWS_MQTT_API |
| 280 |
int aws_mqtt_packet_subscribe_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_subscribe *packet); |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
AWS_MQTT_API |
| 286 |
int aws_mqtt_packet_suback_init( |
| 287 |
struct aws_mqtt_packet_suback *packet, |
| 288 |
struct aws_allocator *allocator, |
| 289 |
uint16_t packet_identifier); |
| 290 |
|
| 291 |
AWS_MQTT_API |
| 292 |
void aws_mqtt_packet_suback_clean_up(struct aws_mqtt_packet_suback *packet); |
| 293 |
|
| 294 |
AWS_MQTT_API |
| 295 |
int aws_mqtt_packet_suback_add_return_code(struct aws_mqtt_packet_suback *packet, uint8_t return_code); |
| 296 |
|
| 297 |
AWS_MQTT_API |
| 298 |
int aws_mqtt_packet_suback_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_suback *packet); |
| 299 |
|
| 300 |
AWS_MQTT_API |
| 301 |
int aws_mqtt_packet_suback_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_suback *packet); |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
AWS_MQTT_API |
| 307 |
int aws_mqtt_packet_unsubscribe_init( |
| 308 |
struct aws_mqtt_packet_unsubscribe *packet, |
| 309 |
struct aws_allocator *allocator, |
| 310 |
uint16_t packet_identifier); |
| 311 |
|
| 312 |
AWS_MQTT_API |
| 313 |
void aws_mqtt_packet_unsubscribe_clean_up(struct aws_mqtt_packet_unsubscribe *packet); |
| 314 |
|
| 315 |
AWS_MQTT_API |
| 316 |
int aws_mqtt_packet_unsubscribe_add_topic( |
| 317 |
struct aws_mqtt_packet_unsubscribe *packet, |
| 318 |
struct aws_byte_cursor topic_filter); |
| 319 |
|
| 320 |
AWS_MQTT_API |
| 321 |
int aws_mqtt_packet_unsubscribe_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_unsubscribe *packet); |
| 322 |
|
| 323 |
AWS_MQTT_API |
| 324 |
int aws_mqtt_packet_unsubscribe_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_unsubscribe *packet); |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
AWS_MQTT_API |
| 330 |
int aws_mqtt_packet_unsuback_init(struct aws_mqtt_packet_ack *packet, uint16_t packet_identifier); |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
AWS_MQTT_API |
| 336 |
int aws_mqtt_packet_pingreq_init(struct aws_mqtt_packet_connection *packet); |
| 337 |
|
| 338 |
AWS_MQTT_API |
| 339 |
int aws_mqtt_packet_pingresp_init(struct aws_mqtt_packet_connection *packet); |
| 340 |
|
| 341 |
AWS_MQTT_API |
| 342 |
int aws_mqtt_packet_disconnect_init(struct aws_mqtt_packet_connection *packet); |
| 343 |
|
| 344 |
AWS_MQTT_API |
| 345 |
int aws_mqtt_packet_connection_encode(struct aws_byte_buf *buf, const struct aws_mqtt_packet_connection *packet); |
| 346 |
|
| 347 |
AWS_MQTT_API |
| 348 |
int aws_mqtt_packet_connection_decode(struct aws_byte_cursor *cur, struct aws_mqtt_packet_connection *packet); |
| 349 |
|
| 350 |
#ifdef __cplusplus |
| 351 |
} |
| 352 |
#endif |
| 353 |
|
| 354 |
#endif |