10 #ifndef BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP 11 #define BOOST_BEAST_WEBSOCKET_DETAIL_FRAME_HPP 18 #include <boost/asio/buffer.hpp> 19 #include <boost/assert.hpp> 20 #include <boost/endian/buffers.hpp> 32 auto const p =
reinterpret_cast< 33 std::uint8_t const*
>(buf);
34 return (p[0]<<8) + p[1];
41 auto const p =
reinterpret_cast< 42 std::uint8_t const*
>(buf);
44 (static_cast<std::uint64_t>(p[0])<<56) +
45 (static_cast<std::uint64_t>(p[1])<<48) +
46 (static_cast<std::uint64_t>(p[2])<<40) +
47 (static_cast<std::uint64_t>(p[3])<<32) +
48 (static_cast<std::uint64_t>(p[4])<<24) +
49 (static_cast<std::uint64_t>(p[5])<<16) +
50 (static_cast<std::uint64_t>(p[6])<< 8) +
58 auto const p =
reinterpret_cast< 59 std::uint8_t const*
>(buf);
62 (
static_cast<std::uint32_t
>(p[1])<< 8) +
63 (
static_cast<std::uint32_t
>(p[2])<<16) +
64 (
static_cast<std::uint32_t
>(p[3])<<24);
71 auto p =
reinterpret_cast<std::uint8_t*
>(buf);
73 p[1] = (v >> 8) & 0xff;
74 p[2] = (v >> 16) & 0xff;
75 p[3] = (v >> 24) & 0xff;
171 if(v >= 1016 && v <= 2999)
183 template<
class DynamicBuffer>
187 using boost::asio::buffer;
188 using boost::asio::buffer_copy;
189 using namespace boost::endian;
192 b[0] = (fh.
fin ? 0x80 : 0x00) | static_cast<std::uint8_t>(fh.
op);
199 b[1] = fh.
mask ? 0x80 : 0x00;
205 else if(fh.
len <= 65535)
208 ::new(&b[2]) big_uint16_buf_t{
209 (std::uint16_t)fh.
len};
215 ::new(&b[2]) big_uint64_buf_t{fh.
len};
223 db.commit(buffer_copy(
224 db.prepare(n), buffer(b)));
230 template<
class Buffers>
234 using boost::asio::buffer_copy;
235 using boost::asio::buffer_size;
236 using boost::asio::mutable_buffers_1;
237 BOOST_ASSERT(buffer_size(bs) <= data.
max_size());
238 data.
resize(buffer_size(bs));
239 buffer_copy(mutable_buffers_1{
246 template<
class Buffers>
251 using boost::asio::buffer;
252 using boost::asio::buffer_copy;
253 using boost::asio::buffer_size;
254 using namespace boost::endian;
255 auto n = buffer_size(bs);
256 BOOST_ASSERT(n <= 125);
271 buffer_copy(buffer(b), cb);
284 buffer_copy(buffer(&cr.
reason[0], n), cb);
bool constexpr is_control(opcode op)
Definition: frame.hpp:138
The endpoint is going away, either because of a server failure or because the browser is navigating a...
Definition: rfc6455.hpp:73
The server is terminating the connection due to a temporary condition, e.g. it is overloaded and is c...
Definition: rfc6455.hpp:100
reason_string reason
The optional utf8-encoded reason string.
Definition: rfc6455.hpp:166
Definition: async_result.hpp:20
size_type constexpr max_size() const
Returns the maximum number of characters that can be stored, excluding the null terminator.
Definition: static_string.hpp:470
bool is_valid_close_code(std::uint16_t v)
Definition: frame.hpp:145
void read_close(close_reason &cr, Buffers const &bs, close_code &code)
Definition: frame.hpp:248
The connection is being terminated because the endpoint received data of a type it cannot accept (for...
Definition: rfc6455.hpp:79
Definition: rfc6455.hpp:129
void write(DynamicBuffer &db, frame_header const &fh)
Definition: frame.hpp:185
Definition: rfc6455.hpp:160
The server is terminating the connection because it is restarting.
Definition: rfc6455.hpp:97
Definition: rfc6455.hpp:111
size_type size() const
Returns the number of characters, excluding the null terminator.
Definition: static_string.hpp:456
std::uint16_t code
The close code.
Definition: rfc6455.hpp:163
The server is terminating the connection because it encountered an unexpected condition that prevente...
Definition: rfc6455.hpp:94
The client is terminating the connection because it expected the server to negotiate one or more exte...
Definition: rfc6455.hpp:91
bool constexpr is_valid(opcode op)
Definition: frame.hpp:131
void resize(std::size_t n)
Definition: static_string.ipp:461
void read_ping(ping_data &data, Buffers const &bs)
Definition: frame.hpp:232
The endpoint is terminating the connection because it received a message that violates its policy...
Definition: rfc6455.hpp:85
std::uint16_t big_uint16_to_native(void const *buf)
Definition: frame.hpp:30
std::uint64_t big_uint64_to_native(void const *buf)
Definition: frame.hpp:39
bool constexpr is_reserved(opcode op)
Definition: frame.hpp:122
The endpoint is terminating the connection because a message was received that contained inconsistent...
Definition: rfc6455.hpp:82
close_code
Definition: rfc6455.hpp:67
Definition: rfc6455.hpp:141
Definition: rfc6455.hpp:123
The endpoint is terminating the connection because a data frame was received that is too large...
Definition: rfc6455.hpp:88
std::uint32_t little_uint32_to_native(void const *buf)
Definition: frame.hpp:56
void native_to_little_uint32(std::uint32_t v, void *buf)
Definition: frame.hpp:69
The endpoint is terminating the connection due to a protocol error.
Definition: rfc6455.hpp:76
Normal closure; the connection successfully completed whatever purpose for which it was created...
Definition: rfc6455.hpp:70
Definition: static_string.hpp:44
Definition: rfc6455.hpp:135
Definition: rfc6455.hpp:117
void consume(std::size_t amount)
Definition: consuming_buffers.ipp:219
opcode
Definition: frame.hpp:79
CharT * data()
Returns a pointer to the first character of a string.
Definition: static_string.hpp:329
bool check_utf8(char const *p, std::size_t n)
Definition: utf8_checker.hpp:334