restinio::websocket::basic::impl Namespace Reference

## Classes

struct | connection_input_t
| Websocket input stuff. More...
struct | expected_data_t
| Data with expected size. More...
class | message_details_t
| Websocket message class with more detailed protocol information. More...
struct | unmasker_t
class | ws_connection_base_t
| WebSocket connection base. More...
class | ws_connection_t
| Context for handling websocket connections. More...
class | ws_outgoing_data_t
| A queue for outgoing buffers. More...
class | ws_parser_t
| Websocket parser. More...
class | ws_protocol_validator_t
| Class for websocket protocol validations. More...

## Typedefs

using | write_groups_queue_t = std::queue< write_group_t >
using | ws_connection_handle_t = std::shared_ptr< ws_connection_base_t >
| Alias for WebSocket connection handle. More...

## Enumerations

enum class | validation_state_t { initial_state , frame_header_is_valid , payload_part_is_valid , frame_is_valid , invalid_opcode , empty_mask_from_client_side , non_final_control_frame , non_zero_rsv_flags , payload_len_is_too_big , continuation_frame_without_data_frame , new_data_frame_without_finishing_previous , invalid_close_code , incorrect_utf8_data }
| States of validated frame. More...

## Functions

bool | check_utf8_is_correct (string_view_t sv) noexcept
constexpr size_t | websocket_header_max_size ()
| Max possible size of websocket frame header (a part before payload). More...
template<typename T >
void | read_number_from_big_endian_bytes (T &number, const raw_data_t &data)
| Read number from buffer with network bytes order. More...
template<int Bytes>
void | write_number_to_big_endian_bytes (std::uint64_t &number, raw_data_t &data)
| Save number to buffer with network bytes order. More...
void | mask_unmask_payload (std::uint32_t masking_key, raw_data_t &payload)
| Do msak/unmask operation with buffer. More...
raw_data_t | write_message_details (const message_details_t &message)
| Serialize websocket message details into bytes buffer. More...
raw_data_t | write_message_details (final_frame_flag_t final_flag, opcode_t opcode, size_t payload_len)
| Serialize websocket message details into bytes buffer. More...
raw_data_t | write_message_details (final_frame_flag_t final_flag, opcode_t opcode, size_t payload_len, std::uint32_t masking_key)
| Serialize websocket message details into bytes buffer. More...
const char * | validation_state_str (validation_state_t state)
| Helper function for logging validation states. More...
bool | is_control_frame (opcode_t opcode)
| Check frame is control frame. More...
bool | is_data_frame (opcode_t opcode)
| Check frame is data frame. More...

## Variables

constexpr size_t | websocket_first_two_bytes_size = 2
| Websocket parser constants. More...
constexpr size_t | websocket_max_payload_size_without_ext = 125
constexpr size_t | websocket_short_ext_payload_length = 2
constexpr size_t | websocket_long_ext_payload_length = 8
constexpr size_t | websocket_short_ext_len_code = 126
constexpr size_t | websocket_long_ext_len_code = 127
constexpr size_t | websocket_masking_key_size = 4
constexpr byte_t | bit_flag_7 = 0x80
constexpr byte_t | bit_flag_6 = 0x40
constexpr byte_t | bit_flag_5 = 0x20
constexpr byte_t | bit_flag_4 = 0x10
constexpr byte_t | opcode_mask = 0x0F
constexpr byte_t | payload_len_mask = 0x7F

## Typedef Documentation

## write_groups_queue_t

using restinio::websocket::basic::impl::write_groups_queue_t = typedef std::queue< write_group_t >

Definition at line 42 of file ws_connection.hpp.

## ws_connection_handle_t

using restinio::websocket::basic::impl::ws_connection_handle_t = typedef std::shared_ptr< ws_connection_base_t >

Alias for WebSocket connection handle.

Definition at line 65 of file ws_connection_base.hpp.

## Enumeration Type Documentation

## validation_state_t

enum class restinio::websocket::basic::impl::validation_state_t

strong

States of validated frame.

Enumerator
initial_state |
frame_header_is_valid |
payload_part_is_valid |
frame_is_valid |
invalid_opcode |
empty_mask_from_client_side |
non_final_control_frame |
non_zero_rsv_flags |
payload_len_is_too_big |
continuation_frame_without_data_frame |
new_data_frame_without_finishing_previous |
invalid_close_code |
incorrect_utf8_data |

Definition at line 28 of file ws_protocol_validator.hpp.

## Function Documentation

## check_utf8_is_correct()

bool restinio::websocket::basic::impl::check_utf8_is_correct | ( | string_view_t | sv | ) |

inlinenoexcept

Definition at line 29 of file utf8.hpp.

## is_control_frame()

bool restinio::websocket::basic::impl::is_control_frame | ( | opcode_t | opcode | ) |

inline

Check frame is control frame.

Returns
  true if frame is control frame.
  false otherwise.

Definition at line 87 of file ws_protocol_validator.hpp.

## is_data_frame()

bool restinio::websocket::basic::impl::is_data_frame | ( | opcode_t | opcode | ) |

inline

Check frame is data frame.

Returns
  true if frame is data frame.
  false otherwise.

Definition at line 104 of file ws_protocol_validator.hpp.

## mask_unmask_payload()

void restinio::websocket::basic::impl::mask_unmask_payload | ( | std::uint32_t | masking_key,
|  | raw_data_t & | payload
| ) |  |

inline

Do msak/unmask operation with buffer.

Definition at line 488 of file ws_parser.hpp.

## read_number_from_big_endian_bytes()

template<typename T >

void restinio::websocket::basic::impl::read_number_from_big_endian_bytes | ( | T & | number,
|  | const raw_data_t & | data
| ) |  |

inline

Read number from buffer with network bytes order.

Definition at line 221 of file ws_parser.hpp.

## validation_state_str()

const char * restinio::websocket::basic::impl::validation_state_str | ( | validation_state_t | state | ) |

inline

Helper function for logging validation states.

Definition at line 55 of file ws_protocol_validator.hpp.

## websocket_header_max_size()

constexpr size_t restinio::websocket::basic::impl::websocket_header_max_size | ( |  | ) |

constexpr

Max possible size of websocket frame header (a part before payload).

Definition at line 46 of file ws_connection.hpp.

## write_message_details() [1/3]

raw_data_t restinio::websocket::basic::impl::write_message_details | ( | const message_details_t & | message | ) |

inline

Serialize websocket message details into bytes buffer.

Returns
  buffer with written websocket message.

Definition at line 515 of file ws_parser.hpp.

## write_message_details() [2/3]

raw_data_t restinio::websocket::basic::impl::write_message_details | ( | final_frame_flag_t | final_flag,
|  | opcode_t | opcode,
|  | size_t | payload_len
| ) |  |

inline

Serialize websocket message details into bytes buffer.

Returns
  buffer with written websocket message.

Definition at line 586 of file ws_parser.hpp.

## write_message_details() [3/3]

raw_data_t restinio::websocket::basic::impl::write_message_details | ( | final_frame_flag_t | final_flag,
|  | opcode_t | opcode,
|  | size_t | payload_len,
|  | std::uint32_t | masking_key
| ) |  |

inline

Serialize websocket message details into bytes buffer.

Returns
  buffer with written websocket message.

Definition at line 600 of file ws_parser.hpp.

## write_number_to_big_endian_bytes()

template<int Bytes>

void restinio::websocket::basic::impl::write_number_to_big_endian_bytes | ( | std::uint64_t & | number,
|  | raw_data_t & | data
| ) |  |

inline

Save number to buffer with network bytes order.

Definition at line 238 of file ws_parser.hpp.

## Variable Documentation

## bit_flag_4

constexpr byte_t restinio::websocket::basic::impl::bit_flag_4 = 0x10

constexpr

Definition at line 52 of file ws_parser.hpp.

## bit_flag_5

constexpr byte_t restinio::websocket::basic::impl::bit_flag_5 = 0x20

constexpr

Definition at line 51 of file ws_parser.hpp.

## bit_flag_6

constexpr byte_t restinio::websocket::basic::impl::bit_flag_6 = 0x40

constexpr

Definition at line 50 of file ws_parser.hpp.

## bit_flag_7

constexpr byte_t restinio::websocket::basic::impl::bit_flag_7 = 0x80

constexpr

Definition at line 49 of file ws_parser.hpp.

## opcode_mask

constexpr byte_t restinio::websocket::basic::impl::opcode_mask = 0x0F

constexpr

Definition at line 53 of file ws_parser.hpp.

## payload_len_mask

constexpr byte_t restinio::websocket::basic::impl::payload_len_mask = 0x7F

constexpr

Definition at line 54 of file ws_parser.hpp.

## websocket_first_two_bytes_size

constexpr size_t restinio::websocket::basic::impl::websocket_first_two_bytes_size = 2

constexpr

Websocket parser constants.

Definition at line 41 of file ws_parser.hpp.

## websocket_long_ext_len_code

constexpr size_t restinio::websocket::basic::impl::websocket_long_ext_len_code = 127

constexpr

Definition at line 46 of file ws_parser.hpp.

## websocket_long_ext_payload_length

constexpr size_t restinio::websocket::basic::impl::websocket_long_ext_payload_length = 8

constexpr

Definition at line 44 of file ws_parser.hpp.

## websocket_masking_key_size

constexpr size_t restinio::websocket::basic::impl::websocket_masking_key_size = 4

constexpr

Definition at line 47 of file ws_parser.hpp.

## websocket_max_payload_size_without_ext

constexpr size_t restinio::websocket::basic::impl::websocket_max_payload_size_without_ext = 125

constexpr

Definition at line 42 of file ws_parser.hpp.

## websocket_short_ext_len_code

constexpr size_t restinio::websocket::basic::impl::websocket_short_ext_len_code = 126

constexpr

Definition at line 45 of file ws_parser.hpp.

## websocket_short_ext_payload_length

constexpr size_t restinio::websocket::basic::impl::websocket_short_ext_payload_length = 2

constexpr

Definition at line 43 of file ws_parser.hpp.