lsquic_frame_common.h revision a74702c6
1/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_frame_common.h 4 */ 5 6#ifndef LSQUIC_FRAME_COMMON_H 7#define LSQUIC_FRAME_COMMON_H 1 8 9enum http_frame_type 10{ 11 HTTP_FRAME_DATA = 0x00, 12 HTTP_FRAME_HEADERS = 0x01, 13 HTTP_FRAME_PRIORITY = 0x02, 14 HTTP_FRAME_RST_STREAM = 0x03, 15 HTTP_FRAME_SETTINGS = 0x04, 16 HTTP_FRAME_PUSH_PROMISE = 0x05, 17 HTTP_FRAME_PING = 0x06, 18 HTTP_FRAME_GOAWAY = 0x07, 19 HTTP_FRAME_WINDOW_UPDATE = 0x08, 20 HTTP_FRAME_CONTINUATION = 0x09, 21 N_HTTP_FRAME_TYPES 22}; 23 24 25enum http_frame_header_flags /* RFC 7540, Section 6.2 */ 26{ 27 HFHF_END_STREAM = 0x01, 28 HFHF_END_HEADERS = 0x04, 29 HFHF_PADDED = 0x08, 30 HFHF_PRIORITY = 0x20, 31}; 32 33 34struct http_frame_header /* RFC 7540, Section 4.1 */ 35{ 36 unsigned char hfh_length[3]; 37 unsigned char hfh_type; /* enum http_frame_type */ 38 unsigned char hfh_flags; 39 unsigned char hfh_stream_id[4]; 40}; 41 42#define hfh_get_length(hfh) ( ((hfh)->hfh_length[0] << 16) | \ 43 ((hfh)->hfh_length[1] << 8) | \ 44 (hfh)->hfh_length[2] ) 45 46enum settings_param /* RFC 7540, Section 6.5.2 */ 47{ 48 SETTINGS_HEADER_TABLE_SIZE = 0x0001, 49 SETTINGS_ENABLE_PUSH = 0x0002, 50 SETTINGS_MAX_CONCURRENT_STREAMS = 0x0003, 51 SETTINGS_INITIAL_WINDOW_SIZE = 0x0004, 52 SETTINGS_MAX_FRAME_SIZE = 0x0005, 53 SETTINGS_MAX_HEADER_LIST_SIZE = 0x0006, 54}; 55 56 57/* This also doubles as HEADERS frame payload prefix: */ 58struct http_prio_frame /* RFC 7540, Section 6.3 */ 59{ 60 unsigned char hpf_stream_id[4]; /* High bit is the exclusive flag */ 61 unsigned char hpf_weight; 62}; 63 64 65struct http_push_promise_frame /* RFC 7540, Section 6.6 */ 66{ 67 unsigned char hppf_promised_id[4]; /* High bit is reserved */ 68}; 69 70 71struct lsquic_http2_setting 72{ 73 uint16_t id; 74 uint32_t value; 75}; 76 77 78const char * 79lsquic_http_setting_id2str (enum settings_param id); 80 81#endif 82