Debian Codegraph @

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

raw symbols SCIP
1 #ifndef AWS_MQTT_PRIVATE_FIXED_HEADER_H
2 #define AWS_MQTT_PRIVATE_FIXED_HEADER_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/common/byte_buf.h>
10
11 #include <aws/mqtt/mqtt.h>
12
13 /* Represents the types of the MQTT control packets [MQTT-2.2.1]. */
14 enum aws_mqtt_packet_type {
15 /* reserved = 0, */
16 AWS_MQTT_PACKET_CONNECT = 1,
17 AWS_MQTT_PACKET_CONNACK,
18 AWS_MQTT_PACKET_PUBLISH,
19 AWS_MQTT_PACKET_PUBACK,
20 AWS_MQTT_PACKET_PUBREC,
21 AWS_MQTT_PACKET_PUBREL,
22 AWS_MQTT_PACKET_PUBCOMP,
23 AWS_MQTT_PACKET_SUBSCRIBE,
24 AWS_MQTT_PACKET_SUBACK,
25 AWS_MQTT_PACKET_UNSUBSCRIBE,
26 AWS_MQTT_PACKET_UNSUBACK,
27 AWS_MQTT_PACKET_PINGREQ,
28 AWS_MQTT_PACKET_PINGRESP,
29 AWS_MQTT_PACKET_DISCONNECT,
30 /* reserved = 15, */
31 };
32
33 /**
34 * Represents the fixed header [MQTT-2.2].
35 */
36 struct aws_mqtt_fixed_header {
37 enum aws_mqtt_packet_type packet_type;
38 size_t remaining_length;
39 uint8_t flags;
40 };
41
42 /**
43 * Get the type of packet from the first byte of the buffer [MQTT-2.2.1].
44 */
45 AWS_MQTT_API enum aws_mqtt_packet_type aws_mqtt_get_packet_type(const uint8_t *buffer);
46
47 /**
48 * Get traits describing a packet described by header [MQTT-2.2.2].
49 */
50 AWS_MQTT_API bool aws_mqtt_packet_has_flags(const struct aws_mqtt_fixed_header *header);
51
52 /**
53 * Write a fixed header to a byte stream.
54 */
55 AWS_MQTT_API int aws_mqtt_fixed_header_encode(struct aws_byte_buf *buf, const struct aws_mqtt_fixed_header *header);
56
57 /**
58 * Read a fixed header from a byte stream.
59 */
60 AWS_MQTT_API int aws_mqtt_fixed_header_decode(struct aws_byte_cursor *cur, struct aws_mqtt_fixed_header *header);
61
62 AWS_MQTT_API int aws_mqtt311_decode_remaining_length(struct aws_byte_cursor *cur, size_t *remaining_length_out);
63
64 #endif /* AWS_MQTT_PRIVATE_FIXED_HEADER_H */