1 /* 2 * Copyright (c) 2023, Emna Rekik 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief HTTP2 frame information. 10 */ 11 12 #ifndef ZEPHYR_INCLUDE_NET_HTTP_SERVER_FRAME_H_ 13 #define ZEPHYR_INCLUDE_NET_HTTP_SERVER_FRAME_H_ 14 15 #include <stdint.h> 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** HTTP2 frame types */ 22 enum http2_frame_type { 23 /** Data frame */ 24 HTTP2_DATA_FRAME = 0x00, 25 /** Headers frame */ 26 HTTP2_HEADERS_FRAME = 0x01, 27 /** Priority frame */ 28 HTTP2_PRIORITY_FRAME = 0x02, 29 /** Reset stream frame */ 30 HTTP2_RST_STREAM_FRAME = 0x03, 31 /** Settings frame */ 32 HTTP2_SETTINGS_FRAME = 0x04, 33 /** Push promise frame */ 34 HTTP2_PUSH_PROMISE_FRAME = 0x05, 35 /** Ping frame */ 36 HTTP2_PING_FRAME = 0x06, 37 /** Goaway frame */ 38 HTTP2_GOAWAY_FRAME = 0x07, 39 /** Window update frame */ 40 HTTP2_WINDOW_UPDATE_FRAME = 0x08, 41 /** Continuation frame */ 42 HTTP2_CONTINUATION_FRAME = 0x09 43 }; 44 45 /** @cond INTERNAL_HIDDEN */ 46 47 #define HTTP2_FLAG_SETTINGS_ACK 0x01 48 #define HTTP2_FLAG_END_HEADERS 0x04 49 #define HTTP2_FLAG_END_STREAM 0x01 50 #define HTTP2_FLAG_PADDED 0x08 51 #define HTTP2_FLAG_PRIORITY 0x20 52 53 #define HTTP2_FRAME_HEADER_SIZE 9 54 #define HTTP2_FRAME_LENGTH_OFFSET 0 55 #define HTTP2_FRAME_TYPE_OFFSET 3 56 #define HTTP2_FRAME_FLAGS_OFFSET 4 57 #define HTTP2_FRAME_STREAM_ID_OFFSET 5 58 #define HTTP2_FRAME_STREAM_ID_MASK 0x7FFFFFFF 59 60 #define HTTP2_HEADERS_FRAME_PRIORITY_LEN 5 61 #define HTTP2_PRIORITY_FRAME_LEN 5 62 #define HTTP2_RST_STREAM_FRAME_LEN 4 63 64 /** @endcond */ 65 66 /** HTTP2 settings field */ 67 struct http2_settings_field { 68 uint16_t id; /**< Field id */ 69 uint32_t value; /**< Field value */ 70 } __packed; 71 72 /** @brief HTTP2 settings */ 73 enum http2_settings { 74 /** Header table size */ 75 HTTP2_SETTINGS_HEADER_TABLE_SIZE = 1, 76 /** Enable push */ 77 HTTP2_SETTINGS_ENABLE_PUSH = 2, 78 /** Maximum number of concurrent streams */ 79 HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS = 3, 80 /** Initial window size */ 81 HTTP2_SETTINGS_INITIAL_WINDOW_SIZE = 4, 82 /** Max frame size */ 83 HTTP2_SETTINGS_MAX_FRAME_SIZE = 5, 84 /** Max header list size */ 85 HTTP2_SETTINGS_MAX_HEADER_LIST_SIZE = 6, 86 }; 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 #endif 93