forked from caosiyang/websocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frame.h
69 lines (46 loc) · 989 Bytes
/
frame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
*
* filename: frame.h
* summary:
* author: caosiyang
* email: [email protected]
*
*/
#ifndef FRAME_H
#define FRAME_H
#include <string.h>
#include <iostream>
#include "tools.h"
using namespace std;
//frame buffer
typedef struct FrameBuffer {
char *data;
uint64_t len;
} frame_buffer_t;
//frame
typedef struct Frame {
uint8_t fin;
uint8_t opcode;
uint8_t mask;
uint64_t payload_len;
unsigned char masking_key[4];
char *payload_data;
} frame_t;
frame_t *frame_new();
void frame_free(frame_t *frame);
bool is_frame_valid(const frame_t *frame);
#if 0
int32_t frame_set(frame_t *frame,
uint8_t fin,
uint8_t opcode,
uint64_t payload_len,
const char *payload_data);
#endif
frame_buffer_t *frame_buffer_new(uint8_t fin,
uint8_t opcode,
uint64_t payload_len,
const char *payload_data);
frame_buffer_t *frame_buffer_new(const frame_t *frame);
void frame_buffer_free(frame_buffer_t *fb);
void print_frame_info(const frame_buffer_t *fb);
#endif