async_mqtt 5.0.0
Loading...
Searching...
No Matches
get_protocol_version.hpp
1// Copyright Takatoshi Kondo 2022
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#if !defined(ASYNC_MQTT_PACKET_GET_PROTOCOL_VERSION_HPP)
8#define ASYNC_MQTT_PACKET_GET_PROTOCOL_VERSION_HPP
9
10#include <async_mqtt/buffer.hpp>
12#include <async_mqtt/packet/copy_to_static_vector.hpp>
13
14namespace async_mqtt {
15
16inline
17protocol_version get_protocol_version(buffer buf) {
18 static_vector<char, 4> sv;
19 // fixed_header
20 buf.remove_prefix(1);
21 if (auto vl_opt = insert_advance_variable_length(buf, sv)) {
22 if (buf.size() >= 6) {
23 return static_cast<protocol_version>(buf[6]);
24 }
25 }
26 return protocol_version::undetermined;
27}
28
29} // async_mqtt
30
31#endif // ASYNC_MQTT_PACKET_GET_PROTOCOL_VERSION_HPP
protocol_version
MQTT protocol version.
Definition protocol_version.hpp:20