lsquic_frame_common.h revision a74702c6
1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */ 250aadb33SDmitri Tikhonov/* 350aadb33SDmitri Tikhonov * lsquic_frame_common.h 450aadb33SDmitri Tikhonov */ 550aadb33SDmitri Tikhonov 650aadb33SDmitri Tikhonov#ifndef LSQUIC_FRAME_COMMON_H 750aadb33SDmitri Tikhonov#define LSQUIC_FRAME_COMMON_H 1 850aadb33SDmitri Tikhonov 950aadb33SDmitri Tikhonovenum http_frame_type 1050aadb33SDmitri Tikhonov{ 1150aadb33SDmitri Tikhonov HTTP_FRAME_DATA = 0x00, 1250aadb33SDmitri Tikhonov HTTP_FRAME_HEADERS = 0x01, 1350aadb33SDmitri Tikhonov HTTP_FRAME_PRIORITY = 0x02, 1450aadb33SDmitri Tikhonov HTTP_FRAME_RST_STREAM = 0x03, 1550aadb33SDmitri Tikhonov HTTP_FRAME_SETTINGS = 0x04, 1650aadb33SDmitri Tikhonov HTTP_FRAME_PUSH_PROMISE = 0x05, 1750aadb33SDmitri Tikhonov HTTP_FRAME_PING = 0x06, 1850aadb33SDmitri Tikhonov HTTP_FRAME_GOAWAY = 0x07, 1950aadb33SDmitri Tikhonov HTTP_FRAME_WINDOW_UPDATE = 0x08, 2050aadb33SDmitri Tikhonov HTTP_FRAME_CONTINUATION = 0x09, 2150aadb33SDmitri Tikhonov N_HTTP_FRAME_TYPES 2250aadb33SDmitri Tikhonov}; 2350aadb33SDmitri Tikhonov 2450aadb33SDmitri Tikhonov 2550aadb33SDmitri Tikhonovenum http_frame_header_flags /* RFC 7540, Section 6.2 */ 2650aadb33SDmitri Tikhonov{ 2750aadb33SDmitri Tikhonov HFHF_END_STREAM = 0x01, 2850aadb33SDmitri Tikhonov HFHF_END_HEADERS = 0x04, 2950aadb33SDmitri Tikhonov HFHF_PADDED = 0x08, 3050aadb33SDmitri Tikhonov HFHF_PRIORITY = 0x20, 3150aadb33SDmitri Tikhonov}; 3250aadb33SDmitri Tikhonov 3350aadb33SDmitri Tikhonov 3450aadb33SDmitri Tikhonovstruct http_frame_header /* RFC 7540, Section 4.1 */ 3550aadb33SDmitri Tikhonov{ 3650aadb33SDmitri Tikhonov unsigned char hfh_length[3]; 3750aadb33SDmitri Tikhonov unsigned char hfh_type; /* enum http_frame_type */ 3850aadb33SDmitri Tikhonov unsigned char hfh_flags; 3950aadb33SDmitri Tikhonov unsigned char hfh_stream_id[4]; 4050aadb33SDmitri Tikhonov}; 4150aadb33SDmitri Tikhonov 4250aadb33SDmitri Tikhonov#define hfh_get_length(hfh) ( ((hfh)->hfh_length[0] << 16) | \ 4350aadb33SDmitri Tikhonov ((hfh)->hfh_length[1] << 8) | \ 4450aadb33SDmitri Tikhonov (hfh)->hfh_length[2] ) 4550aadb33SDmitri Tikhonov 4650aadb33SDmitri Tikhonovenum settings_param /* RFC 7540, Section 6.5.2 */ 4750aadb33SDmitri Tikhonov{ 4850aadb33SDmitri Tikhonov SETTINGS_HEADER_TABLE_SIZE = 0x0001, 4950aadb33SDmitri Tikhonov SETTINGS_ENABLE_PUSH = 0x0002, 5050aadb33SDmitri Tikhonov SETTINGS_MAX_CONCURRENT_STREAMS = 0x0003, 5150aadb33SDmitri Tikhonov SETTINGS_INITIAL_WINDOW_SIZE = 0x0004, 5250aadb33SDmitri Tikhonov SETTINGS_MAX_FRAME_SIZE = 0x0005, 5350aadb33SDmitri Tikhonov SETTINGS_MAX_HEADER_LIST_SIZE = 0x0006, 5450aadb33SDmitri Tikhonov}; 5550aadb33SDmitri Tikhonov 5650aadb33SDmitri Tikhonov 5750aadb33SDmitri Tikhonov/* This also doubles as HEADERS frame payload prefix: */ 5850aadb33SDmitri Tikhonovstruct http_prio_frame /* RFC 7540, Section 6.3 */ 5950aadb33SDmitri Tikhonov{ 6050aadb33SDmitri Tikhonov unsigned char hpf_stream_id[4]; /* High bit is the exclusive flag */ 6150aadb33SDmitri Tikhonov unsigned char hpf_weight; 6250aadb33SDmitri Tikhonov}; 6350aadb33SDmitri Tikhonov 6450aadb33SDmitri Tikhonov 6550aadb33SDmitri Tikhonovstruct http_push_promise_frame /* RFC 7540, Section 6.6 */ 6650aadb33SDmitri Tikhonov{ 6750aadb33SDmitri Tikhonov unsigned char hppf_promised_id[4]; /* High bit is reserved */ 6850aadb33SDmitri Tikhonov}; 6950aadb33SDmitri Tikhonov 7050aadb33SDmitri Tikhonov 7150aadb33SDmitri Tikhonovstruct lsquic_http2_setting 7250aadb33SDmitri Tikhonov{ 7350aadb33SDmitri Tikhonov uint16_t id; 7450aadb33SDmitri Tikhonov uint32_t value; 7550aadb33SDmitri Tikhonov}; 7650aadb33SDmitri Tikhonov 7750aadb33SDmitri Tikhonov 7850aadb33SDmitri Tikhonovconst char * 7950aadb33SDmitri Tikhonovlsquic_http_setting_id2str (enum settings_param id); 8050aadb33SDmitri Tikhonov 8150aadb33SDmitri Tikhonov#endif 82