Add initial support for QUIC, improve logging capabilities.

Add TRACE logging mode
This commit is contained in:
Vadim Vetrov
2024-08-13 20:48:35 +03:00
parent 4a8f0d18a9
commit f3db464b97
12 changed files with 628 additions and 379 deletions

55
quic.h
View File

@@ -2,6 +2,7 @@
#define QUIC_H
#include "types.h"
/**
* @macro
*
@@ -22,38 +23,52 @@
"\x0d\xed\xe3\xde\xf7\x00\xa6\xdb\x81\x93\x81\xbe\x6e\x26\x9d\xcb" \
"\xf9\xbd\x2e\xd9"
#define QUIC_INITIAL_TYPE_V1 0x00
#define QUIC_0_RTT_TYPE_V1 0x01
#define QUIC_HANDSHAKE_TYPE_V1 0x02
#define QUIC_RETRY_TYPE_V1 0x03
#define QUIC_INITIAL_TYPE 0
#define QUIC_0_RTT_TYPE 1
#define QUIC_HANDSHAKE_TYPE 2
#define QUIC_RETRY_TYPE 3
#define QUIC_INITIAL_TYPE_V2 0b01
#define QUIC_0_RTT_TYPE_V2 0b10
#define QUIC_HANDSHAKE_TYPE_V2 0b11
#define QUIC_RETRY_TYPE_V2 0b00
#define QUIC_INITIAL_TYPE_V1 0b00
#define QUIC_0_RTT_TYPE_V1 0b01
#define QUIC_HANDSHAKE_TYPE_V1 0b10
#define QUIC_RETRY_TYPE_V1 0b11
#define quic_convtype_v1(type) (type)
#define QUIC_INITIAL_TYPE_V2 0b01
#define QUIC_0_RTT_TYPE_V2 0b10
#define QUIC_HANDSHAKE_TYPE_V2 0b11
#define QUIC_RETRY_TYPE_V2 0b00
#define quic_convtype_v2(type) (((type) + 1) & 0b11)
#define QUIC_V1 1 // RFC 9000
#define QUIC_V2 0x6b3343cf // RFC 9369
static const uint32_t supported_versions[] = {
QUIC_V1,
QUIC_V2,
};
/**
* Quic Large Header
*/
struct quic_lhdr {
#if __BYTE_ORDER == __LITTLE_ENDIAN
uint8_t number_length: 2;
uint8_t reserved: 2;
uint8_t type: 2;
uint8_t fixed: 1;
uint8_t form: 1;
uint8_t number_length:2;
uint8_t reserved:2;
uint8_t type:2;
uint8_t fixed:1;
uint8_t form:1;
#elif __BYTE_ORDER == __BIG_ENDIAN
uint8_t form: 1;
uint8_t fixed: 1;
uint8_t type: 2;
uint8_t reserved: 2;
uint8_t number_length: 2;
uint8_t form:1;
uint8_t fixed:1;
uint8_t type:2;
uint8_t reserved:2;
uint8_t number_length:2;
#else
#error "Undefined endian"
#endif
uint32_t version;
};
}__attribute__((packed));
/**
* Quic Large Header Ids