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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
* gquic_process.h
*
* Created on: 2019��4��2��
* Author: root
*/
#ifndef SRC_GQUIC_GQUIC_PROCESS_H_
#define SRC_GQUIC_GQUIC_PROCESS_H_
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "gquic.h"
#define VERSION_LEN 4
#define VER_Q046 0x51303436
/**************************************************************************/
/* Public flag */
/**************************************************************************/
#define PACKET_PUBLIC_FLAGS_MAX 0x7f
#define PUBLIC_FLAG_VER_FST_BYTE 0x51
#define PUBLIC_FLAG_VER 0x01
#define PUBLIC_FLAG_RST 0x02
#define PUBLIC_FLAG_NONCE 0x04
#define BYTE_CNTID_8 0x08
#define BYTE_CNTID_0 0x00
enum gquic_connid_len {
PACKET_0BYTE_CONNECTION_ID = 0,
PACKET_8BYTE_CONNECTION_ID = 8
};
#define PKT_NUM_6 0x30
#define PKT_NUM_4 0x20
#define PKT_NUM_2 0x10
#define PKT_NUM_1 0x00
//enum gquic_pkt_num_len {
// PACKET_1BYTE_PACKET_NUMBER = 1,
// PACKET_2BYTE_PACKET_NUMBER = 2,
// PACKET_4BYTE_PACKET_NUMBER = 4,
// PACKET_6BYTE_PACKET_NUMBER = 6
//};
// Used to indicate a QuicSequenceNumberLength using two flag bits.
enum gquic_pkt_num_len_flags {
PACKET_FLAGS_1BYTE_PACKET = 0, // 00
PACKET_FLAGS_2BYTE_PACKET = 1, // 01
PACKET_FLAGS_4BYTE_PACKET = 1 << 1, // 10
PACKET_FLAGS_6BYTE_PACKET = 1 << 1 | 1, // 11
};
//#define PUBLIC_FLAG_MULTIPATH 0x40
#define UNUSE 0x80
#define MSG_AUTH_HASH_LEN 12
#define PUB_HEAD_SEQ_SFT 4
/**************************************************************************/
/* Frame type */
/**************************************************************************/
#define FRAM_SPECIAL 0xE0
#define STREAM 0x80
#define STREAM_F 0x40 //fin
#define STREAM_D 0x20 //data length
#define STREAM_OOO 0x1C //offset length
#define STREAM_SS 0x03 //stream length
#define ACK 0x40
#define ACK_LL 0x0c
#define ACK_MM 0x03
#define ACK_N 0x20
#define CONGESTION_FEEDBACK 0x20
#define PADDING 0x00
#define RST_STREAM 0x01
#define CONNECTION_CLOSE 0x02
#define GOAWAY 0x03
#define WINDOW_UPDATE 0x04
#define BLOCKED 0x05
#define STOP_WAITING 0x06
#define PING 0x07
#define STREAM_ID_1BYTE 0x00
#define STREAM_ID_2BYTE 0x01
#define STREAM_ID_3BYTE 0x02
#define STREAM_ID_4BYTE 0x03
enum frame_type_t{
FRAME_UNKNOWN = 0,
FRAME_STREAM,
FRAME_ACK,
FRAME_CONGESTION_FEEDBACK,
FRAME_PADDING,
FRAME_RST_STREAM,
FRAME_CONNECTION_CLOSE,
FRAME_GOAWAY,
FRAME_WINDOW_UPDATE,
FRAME_BLOCKED,
FRAME_STOP_WAITING,
FRAME_PING
};
/**************************************************************************/
/* Message tag */
/**************************************************************************/
#define CHLO 0x43484C4F
#define SHLO 0x53484C4F
#define REJ 0x52454A00
#define PRST 0x50525354
enum message_tag_t{
MTAG_UNKNOWN = 0,
MTAG_CHLO,
MTAG_SHLO,
MTAG_REJ,
MTAG_PRST
};
struct gquic_frame_hdr{
enum frame_type_t frame_type;
UCHAR is_fin;
UCHAR data_len_byte;
UCHAR offset_len;
UCHAR stream_id_len;
UINT8 stream_id;
UINT16 data_len;
UCHAR padding_len;
enum message_tag_t tag;
UINT32 tag_num;
};
struct gquic_pkt_hdr{
UINT64 connection_id;
int connection_id_len;
UINT8 nonce_flag;
UINT8 reset_flag;
UINT8 version_flag;
UINT32 packet_number_len;
UINT32 version;
UINT8 version_int8;
UINT32 packet_number;
UCHAR auth_hash[MSG_AUTH_HASH_LEN];
// struct gquic_frame_hdr* frame_hdr;
};
/**************************************************************************/
/* Tag */
/**************************************************************************/
#define TAG_PAD 0x50414400
#define TAG_SNI 0x534E4900
#define TAG_VER 0x56455200
#define TAG_CCS 0x43435300
#define TAG_UAID 0x55414944
#define TAG_PDMD 0x50444d44
#define TAG_STK 0x53544b00
#define TAG_SNO 0x534E4F00
#define TAG_PROF 0x50524F46
#define TAG_SCFG 0x53434647
#define TAG_RREJ 0x5252454A
#define TAG_CRT 0x435254FF
#define TAG_AEAD 0x41454144
#define TAG_SCID 0x53434944
#define TAG_PUBS 0x50554253
#define TAG_KEXS 0x4B455853
#define TAG_OBIT 0x4F424954
#define TAG_EXPY 0x45585059
#define TAG_NONC 0x4E4F4E43
#define TAG_MSPC 0x4D535043
#define TAG_TCID 0x54434944
#define TAG_SRBF 0x53524246
#define TAG_ICSL 0x4943534C
#define TAG_SCLS 0x53434C53
#define TAG_COPT 0x434F5054
#define TAG_CCRT 0x43435254
#define TAG_IRTT 0x49525454
#define TAG_CFCW 0x43464357
#define TAG_SFCW 0x53464357
#define TAG_CETV 0x43455456
#define TAG_XLCT 0x584C4354
#define TAG_NONP 0x4E4F4E50
#define TAG_CSCT 0x43534354
#define TAG_CTIM 0x4354494D
#define TAG_MIDS 0x4D494453
#define TAG_FHOL 0x46484F4C
#define TAG_STTL 0x5354544C
#define TAG_SMHL 0x534D484C
#define TAG_TBKP 0x54424B50
/* Public Reset Tag */
#define TAG_RNON 0x524E4F4E
#define TAG_RSEQ 0x52534551
#define TAG_CADR 0x43414452
UINT8 gquic_process(struct streaminfo *pstream, struct quic_stream* a_quic_stream, int thread_seq, void* a_packet);
UINT32 read_offset_len(UINT8 frame_type);
UINT32 read_stream_len(UINT8 frame_type);
UINT32 read_largest_observed_len(UINT8 frame_type);
UINT32 read_missing_packet_len(UINT8 frame_type);
UINT32 get_stream_id(char* g_data_t, UINT8 frame_type, UINT32 *skip_len);
UINT32 read_seq_num_len(UINT8 flags);
int read_conn_id_len(UINT8 flags);
#endif
|