first add
This commit is contained in:
218
src/gquic_process.h
Normal file
218
src/gquic_process.h
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* gquic_process.h
|
||||
*
|
||||
* Created on: 2019<31><39>4<EFBFBD><34>2<EFBFBD><32>
|
||||
* 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,
|
||||
unsigned long long region_flag, int thread_seq, void* a_packet, char* quic_data, UINT32 quic_data_len);
|
||||
//UCHAR is_handshake_pkt(struct quic_stream* a_quic_stream, struct gquic_pkt_hdr* gquic_hdr, char * quic_data, UINT32 quic_data_len, UINT32 offset);
|
||||
//void gquic_proc_unencrypt(struct streaminfo *pstream, struct gquic_pkt_hdr* gquic_hdr, struct quic_stream* a_quic_stream,
|
||||
// unsigned long long region_flag, int thread_seq, void* a_packet, char * quic_data, UINT32 quic_data_len, UINT32 g_pos_t);
|
||||
//UINT8 gquic_proc_tag(struct streaminfo *pstream, struct gquic_pkt_hdr* gquic_hdr, struct quic_stream *a_quic_stream, UINT16 tag_num, UINT8 direction,
|
||||
// unsigned long long region_flag, int thread_seq, void* a_packet, char * quic_data, UINT32 quic_data_len, UINT32 g_pos_t);
|
||||
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, UINT32 offset, UINT8 stream_id_len);
|
||||
UINT32 get_pkn(char* g_data_t, UINT32 offset, UINT8 pkn_len);
|
||||
UINT32 read_seq_num_len(UINT8 flags);
|
||||
int read_conn_id_len(UINT8 flags);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user