diff options
author | Jack Lloyd <[email protected]> | 2016-12-11 15:28:38 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-12-18 16:48:24 -0500 |
commit | f3cb3edb512bdcab498d825886c3366c341b3f78 (patch) | |
tree | 645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/tls/tls_handshake_io.h | |
parent | c1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff) |
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency,
eg make_u32bit becomes make_uint32. The old typedefs remain for now
since probably lots of application code uses them.
Diffstat (limited to 'src/lib/tls/tls_handshake_io.h')
-rw-r--r-- | src/lib/tls/tls_handshake_io.h | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/lib/tls/tls_handshake_io.h b/src/lib/tls/tls_handshake_io.h index 601ac41d9..a9453abcc 100644 --- a/src/lib/tls/tls_handshake_io.h +++ b/src/lib/tls/tls_handshake_io.h @@ -32,22 +32,22 @@ class Handshake_IO public: virtual Protocol_Version initial_record_version() const = 0; - virtual std::vector<byte> send(const Handshake_Message& msg) = 0; + virtual std::vector<uint8_t> send(const Handshake_Message& msg) = 0; virtual bool timeout_check() = 0; - virtual std::vector<byte> format( - const std::vector<byte>& handshake_msg, + virtual std::vector<uint8_t> format( + const std::vector<uint8_t>& handshake_msg, Handshake_Type handshake_type) const = 0; - virtual void add_record(const std::vector<byte>& record, + virtual void add_record(const std::vector<uint8_t>& record, Record_Type type, - u64bit sequence_number) = 0; + uint64_t sequence_number) = 0; /** * Returns (HANDSHAKE_NONE, std::vector<>()) if no message currently available */ - virtual std::pair<Handshake_Type, std::vector<byte>> + virtual std::pair<Handshake_Type, std::vector<uint8_t>> get_next_record(bool expecting_ccs) = 0; Handshake_IO() {} @@ -65,7 +65,7 @@ class Handshake_IO class Stream_Handshake_IO final : public Handshake_IO { public: - typedef std::function<void (byte, const std::vector<byte>&)> writer_fn; + typedef std::function<void (uint8_t, const std::vector<uint8_t>&)> writer_fn; explicit Stream_Handshake_IO(writer_fn writer) : m_send_hs(writer) {} @@ -73,20 +73,20 @@ class Stream_Handshake_IO final : public Handshake_IO bool timeout_check() override { return false; } - std::vector<byte> send(const Handshake_Message& msg) override; + std::vector<uint8_t> send(const Handshake_Message& msg) override; - std::vector<byte> format( - const std::vector<byte>& handshake_msg, + std::vector<uint8_t> format( + const std::vector<uint8_t>& handshake_msg, Handshake_Type handshake_type) const override; - void add_record(const std::vector<byte>& record, + void add_record(const std::vector<uint8_t>& record, Record_Type type, - u64bit sequence_number) override; + uint64_t sequence_number) override; - std::pair<Handshake_Type, std::vector<byte>> + std::pair<Handshake_Type, std::vector<uint8_t>> get_next_record(bool expecting_ccs) override; private: - std::deque<byte> m_queue; + std::deque<uint8_t> m_queue; writer_fn m_send_hs; }; @@ -96,11 +96,11 @@ class Stream_Handshake_IO final : public Handshake_IO class Datagram_Handshake_IO final : public Handshake_IO { public: - typedef std::function<void (u16bit, byte, const std::vector<byte>&)> writer_fn; + typedef std::function<void (uint16_t, uint8_t, const std::vector<uint8_t>&)> writer_fn; Datagram_Handshake_IO(writer_fn writer, class Connection_Sequence_Numbers& seq, - u16bit mtu, u64bit initial_timeout_ms, u64bit max_timeout_ms) : + uint16_t mtu, uint64_t initial_timeout_ms, uint64_t max_timeout_ms) : m_seqs(seq), m_flights(1), m_initial_timeout(initial_timeout_ms), @@ -113,96 +113,96 @@ class Datagram_Handshake_IO final : public Handshake_IO bool timeout_check() override; - std::vector<byte> send(const Handshake_Message& msg) override; + std::vector<uint8_t> send(const Handshake_Message& msg) override; - std::vector<byte> format( - const std::vector<byte>& handshake_msg, + std::vector<uint8_t> format( + const std::vector<uint8_t>& handshake_msg, Handshake_Type handshake_type) const override; - void add_record(const std::vector<byte>& record, + void add_record(const std::vector<uint8_t>& record, Record_Type type, - u64bit sequence_number) override; + uint64_t sequence_number) override; - std::pair<Handshake_Type, std::vector<byte>> + std::pair<Handshake_Type, std::vector<uint8_t>> get_next_record(bool expecting_ccs) override; private: void retransmit_flight(size_t flight); void retransmit_last_flight(); - std::vector<byte> format_fragment( - const byte fragment[], + std::vector<uint8_t> format_fragment( + const uint8_t fragment[], size_t fragment_len, - u16bit frag_offset, - u16bit msg_len, + uint16_t frag_offset, + uint16_t msg_len, Handshake_Type type, - u16bit msg_sequence) const; + uint16_t msg_sequence) const; - std::vector<byte> format_w_seq( - const std::vector<byte>& handshake_msg, + std::vector<uint8_t> format_w_seq( + const std::vector<uint8_t>& handshake_msg, Handshake_Type handshake_type, - u16bit msg_sequence) const; + uint16_t msg_sequence) const; - std::vector<byte> send_message(u16bit msg_seq, u16bit epoch, + std::vector<uint8_t> send_message(uint16_t msg_seq, uint16_t epoch, Handshake_Type msg_type, - const std::vector<byte>& msg); + const std::vector<uint8_t>& msg); class Handshake_Reassembly { public: - void add_fragment(const byte fragment[], + void add_fragment(const uint8_t fragment[], size_t fragment_length, size_t fragment_offset, - u16bit epoch, - byte msg_type, + uint16_t epoch, + uint8_t msg_type, size_t msg_length); bool complete() const; - u16bit epoch() const { return m_epoch; } + uint16_t epoch() const { return m_epoch; } - std::pair<Handshake_Type, std::vector<byte>> message() const; + std::pair<Handshake_Type, std::vector<uint8_t>> message() const; private: - byte m_msg_type = HANDSHAKE_NONE; + uint8_t m_msg_type = HANDSHAKE_NONE; size_t m_msg_length = 0; - u16bit m_epoch = 0; + uint16_t m_epoch = 0; // vector<bool> m_seen; - // vector<byte> m_fragments - std::map<size_t, byte> m_fragments; - std::vector<byte> m_message; + // vector<uint8_t> m_fragments + std::map<size_t, uint8_t> m_fragments; + std::vector<uint8_t> m_message; }; struct Message_Info { - Message_Info(u16bit e, Handshake_Type mt, const std::vector<byte>& msg) : + Message_Info(uint16_t e, Handshake_Type mt, const std::vector<uint8_t>& msg) : epoch(e), msg_type(mt), msg_bits(msg) {} Message_Info(const Message_Info& other) = default; Message_Info() : epoch(0xFFFF), msg_type(HANDSHAKE_NONE) {} - u16bit epoch; + uint16_t epoch; Handshake_Type msg_type; - std::vector<byte> msg_bits; + std::vector<uint8_t> msg_bits; }; class Connection_Sequence_Numbers& m_seqs; - std::map<u16bit, Handshake_Reassembly> m_messages; - std::set<u16bit> m_ccs_epochs; - std::vector<std::vector<u16bit>> m_flights; - std::map<u16bit, Message_Info> m_flight_data; + std::map<uint16_t, Handshake_Reassembly> m_messages; + std::set<uint16_t> m_ccs_epochs; + std::vector<std::vector<uint16_t>> m_flights; + std::map<uint16_t, Message_Info> m_flight_data; - u64bit m_initial_timeout = 0; - u64bit m_max_timeout = 0; + uint64_t m_initial_timeout = 0; + uint64_t m_max_timeout = 0; - u64bit m_last_write = 0; - u64bit m_next_timeout = 0; + uint64_t m_last_write = 0; + uint64_t m_next_timeout = 0; - u16bit m_in_message_seq = 0; - u16bit m_out_message_seq = 0; + uint16_t m_in_message_seq = 0; + uint16_t m_out_message_seq = 0; writer_fn m_send_hs; - u16bit m_mtu; + uint16_t m_mtu; }; } |