forked from halfgaar/FlashMQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packetdatatypes.h
107 lines (83 loc) · 2.61 KB
/
packetdatatypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef PACKETDATATYPES_H
#define PACKETDATATYPES_H
#include <optional>
#include "mqtt5properties.h"
struct ConnectData
{
uint8_t protocol_level_byte = 0;
bool bridge = false;
// Flags
bool password_flag = false;
bool will_retain = false;
uint8_t will_qos = false;
bool will_flag = false;
bool clean_start = false;
uint16_t keep_alive = 0;
// Content from properties
uint16_t client_receive_max;
uint32_t session_expire;
uint32_t max_outgoing_packet_size;
uint16_t max_outgoing_topic_aliases = 0; // Default MUST BE 0, meaning server won't initiate aliases;
bool request_response_information = false;
bool request_problem_information = false;
std::string authenticationMethod;
std::string authenticationData;
// Content from Payload
std::string client_id;
WillPublish willpublish;
std::optional<std::string> username;
std::string password;
Mqtt5PropertyBuilder builder;
ConnectData();
};
struct ConnAckData
{
// Flags
bool sessionPresent = false;
uint32_t session_expire = 0;
uint16_t client_receive_max;
uint8_t max_qos = 2;
uint32_t max_outgoing_packet_size;
uint16_t max_outgoing_topic_aliases = 0; // Default MUST BE 0, meaning we won't initiate aliases unless the other side says we can.
std::string assigned_client_id;
uint16_t keep_alive = 0;
std::string response_information;
std::string server_reference;
bool shared_subscriptions_available = true;
bool retained_available = true;
ReasonCodes reasonCode = ReasonCodes::ImplementationSpecificError; // default something that is never a parse result;
std::string authMethod;
std::string authData;
ConnAckData();
};
struct AuthPacketData
{
std::string method;
std::string data;
ReasonCodes reasonCode = ReasonCodes::ImplementationSpecificError; // default something that is never a parse result;
};
struct DisconnectData
{
ReasonCodes reasonCode = ReasonCodes::Success;
std::string reasonString;
bool session_expiry_interval_set = false;
uint32_t session_expiry_interval = 0;
};
struct SubAckData
{
uint16_t packet_id;
std::string reasonString;
std::vector<uint8_t> subAckCodes;
};
struct PubRecData
{
ReasonCodes reasonCode = ReasonCodes::Success; // Default when not specified, or MQTT3;
};
#endif // PACKETDATATYPES_H