This repository has been archived on 2025-03-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mqttd/src/libmqttd/network/packet_interface/packet_interface.hpp
brenodetomini 886ee7f281 fix: fixing int_vb and connect_ack
Fixing default constructor of int_vb to initalize values to 0
Implementing basic connect ACK
Implemeting basic send function in session
2024-02-11 13:29:01 -03:00

37 lines
1.1 KiB
C++

#ifndef INCLUDE_NETWORK_CONTROL_PACKET_HPP_
#define INCLUDE_NETWORK_CONTROL_PACKET_HPP_
#include "fixed_header.hpp"
#include <exceptions.hpp>
#include <bit.hpp>
#include <types.hpp>
#include <variable_byte_int.hpp>
#include <vector>
class PacketInterface {
public:
PacketInterface(const std::vector<std::byte> &);
PacketInterface(PacketInterface &);
PacketInterface(){};
~PacketInterface() = default;
inline uint length() const { return sizeof(this->fixed_header) + this->fixed_header.remaining_length; }
inline PacketType get_packet_type() const { return this->fixed_header.packet_type; };
inline std::bitset<4> get_packet_flags() const { return this->fixed_header.packet_flags; };
virtual std::string as_string() const;
virtual std::vector<std::byte> as_bytes();
protected:
std::vector<std::byte> raw_data;
FixedHeader fixed_header;
virtual void parse_variable_header() { throw NotImplemented(); };
virtual void parse_payload() { throw NotImplemented(); };
std::vector<std::byte>::const_iterator variable_header_start_byte;
};
#endif // INCLUDE_NETWORK_CONTROL_PACKET_HPP_