RESTinio
|
Class for websocket protocol validations. More...
#include <ws_protocol_validator.hpp>
Public Member Functions | |
ws_protocol_validator_t ()=default | |
ws_protocol_validator_t (bool do_unmask) | |
validation_state_t | process_new_frame (const message_details_t &frame) |
Start work with new frame. More... | |
validation_state_t | process_next_payload_part (const char *data, size_t size) |
Validate next part of current frame. More... | |
validation_state_t | process_and_unmask_next_payload_part (char *data, size_t size) |
Validate next part of current frame and reset source part to unmasked data. More... | |
validation_state_t | finish_frame () |
Make final checks of payload if it is necessary and reset state. More... | |
void | reset () |
Reset to initial state. More... | |
Private Types | |
enum class | working_state_t { empty_state , processing_frame } |
Validator's orking states. More... | |
enum class | previous_data_frame_t { none , text , binary } |
Previous unfinished data frame type. More... | |
Private Member Functions | |
bool | validate_frame_header (const message_details_t &frame) |
Validate frame header. More... | |
std::uint8_t | process_payload_byte (std::uint8_t byte) |
Process payload byte. More... | |
bool | check_previous_frame_type (opcode_t opcode) |
Check previous frame type. More... | |
void | validate_close_code (uint16_t close_code) |
Validate close code. More... | |
bool | is_state_still_valid () const |
Check validation state is still valid. More... | |
void | set_validation_state (validation_state_t state) |
Try to set validation state. More... | |
Private Attributes | |
validation_state_t | m_validation_state |
Current validation state. More... | |
working_state_t | m_working_state { working_state_t::empty_state } |
Working state. More... | |
previous_data_frame_t | m_previous_data_frame |
Previous unfinished data frame. More... | |
message_details_t | m_current_frame |
Current frame details. More... | |
expected_data_t | m_expected_close_code |
Buffer for accumulating 2 bytes of close code. More... | |
restinio::utils::utf8_checker_t | m_utf8_checker |
UTF-8 checker for text frames and close frames. More... | |
bool | m_unmask_flag { false } |
This flag set if it's need to unmask payload parts. More... | |
unmasker_t | m_unmasker |
Unmask payload coming from client side. More... | |
Class for websocket protocol validations.
This class checks:
text frame and close frame are with valid uff-8 payload; close frame has a valid close code; continuation chunks of text frame have valid utf-8 text; there is invalid situation when continuation frame came without any data frame. continuation frame or control frame is wating after data frame with fin flag set in 0. opcode has a valid code control frame can't be fragmented.
Definition at line 194 of file ws_protocol_validator.hpp.
|
strongprivate |
Previous unfinished data frame type.
It needs for understanding what kind of data is present in current continued frames.
Enumerator | |
---|---|
none | |
text | |
binary |
Definition at line 553 of file ws_protocol_validator.hpp.
|
strongprivate |
Validator's orking states.
Enumerator | |
---|---|
empty_state | Waiting for new frame. |
processing_frame | Frame is processing now. |
Definition at line 540 of file ws_protocol_validator.hpp.
|
default |
|
inline |
Definition at line 200 of file ws_protocol_validator.hpp.
|
inlineprivate |
Check previous frame type.
Need for following cases:
1) check current frame is not continuation frame withot any data frame before. 2) check current frame is not new data frame with unfinished other data frame before.
Definition at line 460 of file ws_protocol_validator.hpp.
|
inline |
Make final checks of payload if it is necessary and reset state.
Definition at line 303 of file ws_protocol_validator.hpp.
|
inlineprivate |
Check validation state is still valid.
Definition at line 510 of file ws_protocol_validator.hpp.
|
inline |
Validate next part of current frame and reset source part to unmasked data.
Definition at line 278 of file ws_protocol_validator.hpp.
|
inline |
Start work with new frame.
Definition at line 211 of file ws_protocol_validator.hpp.
|
inline |
Validate next part of current frame.
Definition at line 253 of file ws_protocol_validator.hpp.
|
inlineprivate |
Process payload byte.
Do all necessary validations with payload byte.
Definition at line 406 of file ws_protocol_validator.hpp.
|
inline |
Reset to initial state.
Definition at line 341 of file ws_protocol_validator.hpp.
|
inlineprivate |
Try to set validation state.
Set validation state with new value.
Definition at line 523 of file ws_protocol_validator.hpp.
|
inlineprivate |
Validate close code.
Definition at line 485 of file ws_protocol_validator.hpp.
|
inlineprivate |
Validate frame header.
Definition at line 361 of file ws_protocol_validator.hpp.
|
private |
Current frame details.
Definition at line 568 of file ws_protocol_validator.hpp.
|
private |
Buffer for accumulating 2 bytes of close code.
Definition at line 571 of file ws_protocol_validator.hpp.
|
private |
Previous unfinished data frame.
Definition at line 564 of file ws_protocol_validator.hpp.
|
private |
This flag set if it's need to unmask payload parts.
Definition at line 577 of file ws_protocol_validator.hpp.
|
private |
Unmask payload coming from client side.
Definition at line 580 of file ws_protocol_validator.hpp.
|
private |
UTF-8 checker for text frames and close frames.
Definition at line 574 of file ws_protocol_validator.hpp.
|
private |
Current validation state.
Normal case is sequence of states: frame_header_is_valid -> payload_part_is_valid -> frame_is_valid.
After set in invalid state validator will save this state until frame will be finished or validator will be reset.
Definition at line 536 of file ws_protocol_validator.hpp.
|
private |
Working state.
Definition at line 561 of file ws_protocol_validator.hpp.