line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#pragma once |
2
|
|
|
|
|
|
|
#include "inc.h" |
3
|
|
|
|
|
|
|
#include |
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
namespace panda { namespace protocol { namespace websocket { |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
using panda::string; |
9
|
|
|
|
|
|
|
using panda::IteratorPair; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
struct FrameHeader { |
12
|
|
|
|
|
|
|
Opcode opcode; |
13
|
|
|
|
|
|
|
bool fin; |
14
|
|
|
|
|
|
|
bool rsv1; |
15
|
|
|
|
|
|
|
bool rsv2; |
16
|
|
|
|
|
|
|
bool rsv3; |
17
|
|
|
|
|
|
|
bool has_mask; |
18
|
|
|
|
|
|
|
uint32_t mask; |
19
|
|
|
|
|
|
|
uint64_t length; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
FrameHeader () : mask(0), length(0), _state(State::FIRST), _len16(0) {} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
FrameHeader (Opcode opcode, bool final, bool rsv1, bool rsv2, bool rsv3, bool has_mask, uint32_t mask) : |
24
|
|
|
|
|
|
|
opcode(opcode), fin(final), rsv1(rsv1), rsv2(rsv2), rsv3(rsv3), has_mask(has_mask), mask(mask) {} |
25
|
|
|
|
|
|
|
|
26
|
2434
|
|
|
|
|
|
bool is_control () const { return is_control_opcode(opcode); } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
bool parse (string& buf); |
29
|
|
|
|
|
|
|
string compile (size_t plen) const; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
void reset () { |
32
|
|
|
|
|
|
|
mask = 0; |
33
|
|
|
|
|
|
|
length = 0; |
34
|
|
|
|
|
|
|
_state = State::FIRST; |
35
|
|
|
|
|
|
|
_len16 = 0; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
static bool parse_close_payload (const string& payload, uint16_t& code, string& message); |
39
|
|
|
|
|
|
|
static string compile_close_payload (uint16_t code, const string& message); |
40
|
|
|
|
|
|
|
|
41
|
2876
|
|
|
|
|
|
static bool is_control_opcode (Opcode opcode) { return opcode >= Opcode::CLOSE; } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
private: |
45
|
|
|
|
|
|
|
enum class State { FIRST, SECOND, LENGTH, MASK, DONE }; |
46
|
|
|
|
|
|
|
State _state; |
47
|
|
|
|
|
|
|
uint8_t _slen; |
48
|
|
|
|
|
|
|
uint16_t _len16; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
string _compile_header (size_t plen); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
}}} |