11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * nghttp2 - HTTP/2 C Library 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Copyright (c) 2012 Tatsuhiro Tsujikawa 51cb0ef41Sopenharmony_ci * 61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 71cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the 81cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 91cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 101cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 111cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 121cb0ef41Sopenharmony_ci * the following conditions: 131cb0ef41Sopenharmony_ci * 141cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be 151cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software. 161cb0ef41Sopenharmony_ci * 171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 181cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 191cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 201cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 211cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 221cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 231cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 241cb0ef41Sopenharmony_ci */ 251cb0ef41Sopenharmony_ci#ifndef NGHTTP2_SESSION_H 261cb0ef41Sopenharmony_ci#define NGHTTP2_SESSION_H 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci#ifdef HAVE_CONFIG_H 291cb0ef41Sopenharmony_ci# include <config.h> 301cb0ef41Sopenharmony_ci#endif /* HAVE_CONFIG_H */ 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci#include <nghttp2/nghttp2.h> 331cb0ef41Sopenharmony_ci#include "nghttp2_map.h" 341cb0ef41Sopenharmony_ci#include "nghttp2_frame.h" 351cb0ef41Sopenharmony_ci#include "nghttp2_hd.h" 361cb0ef41Sopenharmony_ci#include "nghttp2_stream.h" 371cb0ef41Sopenharmony_ci#include "nghttp2_outbound_item.h" 381cb0ef41Sopenharmony_ci#include "nghttp2_int.h" 391cb0ef41Sopenharmony_ci#include "nghttp2_buf.h" 401cb0ef41Sopenharmony_ci#include "nghttp2_callbacks.h" 411cb0ef41Sopenharmony_ci#include "nghttp2_mem.h" 421cb0ef41Sopenharmony_ci#include "nghttp2_ratelim.h" 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci/* The global variable for tests where we want to disable strict 451cb0ef41Sopenharmony_ci preface handling. */ 461cb0ef41Sopenharmony_ciextern int nghttp2_enable_strict_preface; 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci/* 491cb0ef41Sopenharmony_ci * Option flags. 501cb0ef41Sopenharmony_ci */ 511cb0ef41Sopenharmony_citypedef enum { 521cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE = 1 << 0, 531cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC = 1 << 1, 541cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_HTTP_MESSAGING = 1 << 2, 551cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3, 561cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4, 571cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_SERVER_FALLBACK_RFC7540_PRIORITIES = 1 << 5, 581cb0ef41Sopenharmony_ci NGHTTP2_OPTMASK_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION = 1 << 6, 591cb0ef41Sopenharmony_ci} nghttp2_optmask; 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ci/* 621cb0ef41Sopenharmony_ci * bitmask for built-in type to enable the default handling for that 631cb0ef41Sopenharmony_ci * type of the frame. 641cb0ef41Sopenharmony_ci */ 651cb0ef41Sopenharmony_citypedef enum { 661cb0ef41Sopenharmony_ci NGHTTP2_TYPEMASK_NONE = 0, 671cb0ef41Sopenharmony_ci NGHTTP2_TYPEMASK_ALTSVC = 1 << 0, 681cb0ef41Sopenharmony_ci NGHTTP2_TYPEMASK_ORIGIN = 1 << 1, 691cb0ef41Sopenharmony_ci NGHTTP2_TYPEMASK_PRIORITY_UPDATE = 1 << 2 701cb0ef41Sopenharmony_ci} nghttp2_typemask; 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_citypedef enum { 731cb0ef41Sopenharmony_ci NGHTTP2_OB_POP_ITEM, 741cb0ef41Sopenharmony_ci NGHTTP2_OB_SEND_DATA, 751cb0ef41Sopenharmony_ci NGHTTP2_OB_SEND_NO_COPY, 761cb0ef41Sopenharmony_ci NGHTTP2_OB_SEND_CLIENT_MAGIC 771cb0ef41Sopenharmony_ci} nghttp2_outbound_state; 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_citypedef struct { 801cb0ef41Sopenharmony_ci nghttp2_outbound_item *item; 811cb0ef41Sopenharmony_ci nghttp2_bufs framebufs; 821cb0ef41Sopenharmony_ci nghttp2_outbound_state state; 831cb0ef41Sopenharmony_ci} nghttp2_active_outbound_item; 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci/* Buffer length for inbound raw byte stream used in 861cb0ef41Sopenharmony_ci nghttp2_session_recv(). */ 871cb0ef41Sopenharmony_ci#define NGHTTP2_INBOUND_BUFFER_LENGTH 16384 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_ci/* The default maximum number of incoming reserved streams */ 901cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_INCOMING_RESERVED_STREAMS 200 911cb0ef41Sopenharmony_ci 921cb0ef41Sopenharmony_ci/* Even if we have less SETTINGS_MAX_CONCURRENT_STREAMS than this 931cb0ef41Sopenharmony_ci number, we keep NGHTTP2_MIN_IDLE_STREAMS streams in idle state */ 941cb0ef41Sopenharmony_ci#define NGHTTP2_MIN_IDLE_STREAMS 16 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci/* The maximum number of items in outbound queue, which is considered 971cb0ef41Sopenharmony_ci as flooding caused by peer. All frames are not considered here. 981cb0ef41Sopenharmony_ci We only consider PING + ACK and SETTINGS + ACK. This is because 991cb0ef41Sopenharmony_ci they both are response to the frame initiated by peer and peer can 1001cb0ef41Sopenharmony_ci send as many of them as they want. If peer does not read network, 1011cb0ef41Sopenharmony_ci response frames are stacked up, which leads to memory exhaustion. 1021cb0ef41Sopenharmony_ci The value selected here is arbitrary, but safe value and if we have 1031cb0ef41Sopenharmony_ci these frames in this number, it is considered suspicious. */ 1041cb0ef41Sopenharmony_ci#define NGHTTP2_DEFAULT_MAX_OBQ_FLOOD_ITEM 1000 1051cb0ef41Sopenharmony_ci 1061cb0ef41Sopenharmony_ci/* The default value of maximum number of concurrent streams. */ 1071cb0ef41Sopenharmony_ci#define NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS 0xffffffffu 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci/* The default values for stream reset rate limiter. */ 1101cb0ef41Sopenharmony_ci#define NGHTTP2_DEFAULT_STREAM_RESET_BURST 1000 1111cb0ef41Sopenharmony_ci#define NGHTTP2_DEFAULT_STREAM_RESET_RATE 33 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci/* Internal state when receiving incoming frame */ 1141cb0ef41Sopenharmony_citypedef enum { 1151cb0ef41Sopenharmony_ci /* Receiving frame header */ 1161cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_CLIENT_MAGIC, 1171cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_FIRST_SETTINGS, 1181cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_HEAD, 1191cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_NBYTE, 1201cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_HEADER_BLOCK, 1211cb0ef41Sopenharmony_ci NGHTTP2_IB_IGN_HEADER_BLOCK, 1221cb0ef41Sopenharmony_ci NGHTTP2_IB_IGN_PAYLOAD, 1231cb0ef41Sopenharmony_ci NGHTTP2_IB_FRAME_SIZE_ERROR, 1241cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_SETTINGS, 1251cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_GOAWAY_DEBUG, 1261cb0ef41Sopenharmony_ci NGHTTP2_IB_EXPECT_CONTINUATION, 1271cb0ef41Sopenharmony_ci NGHTTP2_IB_IGN_CONTINUATION, 1281cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_PAD_DATA, 1291cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_DATA, 1301cb0ef41Sopenharmony_ci NGHTTP2_IB_IGN_DATA, 1311cb0ef41Sopenharmony_ci NGHTTP2_IB_IGN_ALL, 1321cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_ALTSVC_PAYLOAD, 1331cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_ORIGIN_PAYLOAD, 1341cb0ef41Sopenharmony_ci NGHTTP2_IB_READ_EXTENSION_PAYLOAD 1351cb0ef41Sopenharmony_ci} nghttp2_inbound_state; 1361cb0ef41Sopenharmony_ci 1371cb0ef41Sopenharmony_citypedef struct { 1381cb0ef41Sopenharmony_ci nghttp2_frame frame; 1391cb0ef41Sopenharmony_ci /* Storage for extension frame payload. frame->ext.payload points 1401cb0ef41Sopenharmony_ci to this structure to avoid frequent memory allocation. */ 1411cb0ef41Sopenharmony_ci nghttp2_ext_frame_payload ext_frame_payload; 1421cb0ef41Sopenharmony_ci /* The received SETTINGS entry. For the standard settings entries, 1431cb0ef41Sopenharmony_ci we only keep the last seen value. For 1441cb0ef41Sopenharmony_ci SETTINGS_HEADER_TABLE_SIZE, we also keep minimum value in the 1451cb0ef41Sopenharmony_ci last index. */ 1461cb0ef41Sopenharmony_ci nghttp2_settings_entry *iv; 1471cb0ef41Sopenharmony_ci /* buffer pointers to small buffer, raw_sbuf */ 1481cb0ef41Sopenharmony_ci nghttp2_buf sbuf; 1491cb0ef41Sopenharmony_ci /* buffer pointers to large buffer, raw_lbuf */ 1501cb0ef41Sopenharmony_ci nghttp2_buf lbuf; 1511cb0ef41Sopenharmony_ci /* Large buffer, malloced on demand */ 1521cb0ef41Sopenharmony_ci uint8_t *raw_lbuf; 1531cb0ef41Sopenharmony_ci /* The number of entry filled in |iv| */ 1541cb0ef41Sopenharmony_ci size_t niv; 1551cb0ef41Sopenharmony_ci /* The number of entries |iv| can store. */ 1561cb0ef41Sopenharmony_ci size_t max_niv; 1571cb0ef41Sopenharmony_ci /* How many bytes we still need to receive for current frame */ 1581cb0ef41Sopenharmony_ci size_t payloadleft; 1591cb0ef41Sopenharmony_ci /* padding length for the current frame */ 1601cb0ef41Sopenharmony_ci size_t padlen; 1611cb0ef41Sopenharmony_ci nghttp2_inbound_state state; 1621cb0ef41Sopenharmony_ci /* Small fixed sized buffer. */ 1631cb0ef41Sopenharmony_ci uint8_t raw_sbuf[32]; 1641cb0ef41Sopenharmony_ci} nghttp2_inbound_frame; 1651cb0ef41Sopenharmony_ci 1661cb0ef41Sopenharmony_citypedef struct { 1671cb0ef41Sopenharmony_ci uint32_t header_table_size; 1681cb0ef41Sopenharmony_ci uint32_t enable_push; 1691cb0ef41Sopenharmony_ci uint32_t max_concurrent_streams; 1701cb0ef41Sopenharmony_ci uint32_t initial_window_size; 1711cb0ef41Sopenharmony_ci uint32_t max_frame_size; 1721cb0ef41Sopenharmony_ci uint32_t max_header_list_size; 1731cb0ef41Sopenharmony_ci uint32_t enable_connect_protocol; 1741cb0ef41Sopenharmony_ci uint32_t no_rfc7540_priorities; 1751cb0ef41Sopenharmony_ci} nghttp2_settings_storage; 1761cb0ef41Sopenharmony_ci 1771cb0ef41Sopenharmony_citypedef enum { 1781cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_NONE = 0, 1791cb0ef41Sopenharmony_ci /* Flag means that connection should be terminated after sending GOAWAY. */ 1801cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_TERM_ON_SEND = 0x1, 1811cb0ef41Sopenharmony_ci /* Flag means GOAWAY to terminate session has been sent */ 1821cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_TERM_SENT = 0x2, 1831cb0ef41Sopenharmony_ci /* Flag means GOAWAY was sent */ 1841cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_SENT = 0x4, 1851cb0ef41Sopenharmony_ci /* Flag means GOAWAY was received */ 1861cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_RECV = 0x8, 1871cb0ef41Sopenharmony_ci /* Flag means GOAWAY has been submitted at least once */ 1881cb0ef41Sopenharmony_ci NGHTTP2_GOAWAY_SUBMITTED = 0x10 1891cb0ef41Sopenharmony_ci} nghttp2_goaway_flag; 1901cb0ef41Sopenharmony_ci 1911cb0ef41Sopenharmony_ci/* nghttp2_inflight_settings stores the SETTINGS entries which local 1921cb0ef41Sopenharmony_ci endpoint has sent to the remote endpoint, and has not received ACK 1931cb0ef41Sopenharmony_ci yet. */ 1941cb0ef41Sopenharmony_cistruct nghttp2_inflight_settings { 1951cb0ef41Sopenharmony_ci struct nghttp2_inflight_settings *next; 1961cb0ef41Sopenharmony_ci nghttp2_settings_entry *iv; 1971cb0ef41Sopenharmony_ci size_t niv; 1981cb0ef41Sopenharmony_ci}; 1991cb0ef41Sopenharmony_ci 2001cb0ef41Sopenharmony_citypedef struct nghttp2_inflight_settings nghttp2_inflight_settings; 2011cb0ef41Sopenharmony_ci 2021cb0ef41Sopenharmony_cistruct nghttp2_session { 2031cb0ef41Sopenharmony_ci nghttp2_map /* <nghttp2_stream*> */ streams; 2041cb0ef41Sopenharmony_ci /* root of dependency tree*/ 2051cb0ef41Sopenharmony_ci nghttp2_stream root; 2061cb0ef41Sopenharmony_ci /* Queue for outbound urgent frames (PING and SETTINGS) */ 2071cb0ef41Sopenharmony_ci nghttp2_outbound_queue ob_urgent; 2081cb0ef41Sopenharmony_ci /* Queue for non-DATA frames */ 2091cb0ef41Sopenharmony_ci nghttp2_outbound_queue ob_reg; 2101cb0ef41Sopenharmony_ci /* Queue for outbound stream-creating HEADERS (request or push 2111cb0ef41Sopenharmony_ci response) frame, which are subject to 2121cb0ef41Sopenharmony_ci SETTINGS_MAX_CONCURRENT_STREAMS limit. */ 2131cb0ef41Sopenharmony_ci nghttp2_outbound_queue ob_syn; 2141cb0ef41Sopenharmony_ci /* Queues for DATA frames which is used when 2151cb0ef41Sopenharmony_ci SETTINGS_NO_RFC7540_PRIORITIES is enabled. This implements RFC 2161cb0ef41Sopenharmony_ci 9218 extensible prioritization scheme. */ 2171cb0ef41Sopenharmony_ci struct { 2181cb0ef41Sopenharmony_ci nghttp2_pq ob_data; 2191cb0ef41Sopenharmony_ci } sched[NGHTTP2_EXTPRI_URGENCY_LEVELS]; 2201cb0ef41Sopenharmony_ci nghttp2_active_outbound_item aob; 2211cb0ef41Sopenharmony_ci nghttp2_inbound_frame iframe; 2221cb0ef41Sopenharmony_ci nghttp2_hd_deflater hd_deflater; 2231cb0ef41Sopenharmony_ci nghttp2_hd_inflater hd_inflater; 2241cb0ef41Sopenharmony_ci nghttp2_session_callbacks callbacks; 2251cb0ef41Sopenharmony_ci /* Memory allocator */ 2261cb0ef41Sopenharmony_ci nghttp2_mem mem; 2271cb0ef41Sopenharmony_ci void *user_data; 2281cb0ef41Sopenharmony_ci /* Points to the latest incoming closed stream. NULL if there is no 2291cb0ef41Sopenharmony_ci closed stream. Only used when session is initialized as 2301cb0ef41Sopenharmony_ci server. */ 2311cb0ef41Sopenharmony_ci nghttp2_stream *closed_stream_head; 2321cb0ef41Sopenharmony_ci /* Points to the oldest incoming closed stream. NULL if there is no 2331cb0ef41Sopenharmony_ci closed stream. Only used when session is initialized as 2341cb0ef41Sopenharmony_ci server. */ 2351cb0ef41Sopenharmony_ci nghttp2_stream *closed_stream_tail; 2361cb0ef41Sopenharmony_ci /* Points to the latest idle stream. NULL if there is no idle 2371cb0ef41Sopenharmony_ci stream. Only used when session is initialized as server .*/ 2381cb0ef41Sopenharmony_ci nghttp2_stream *idle_stream_head; 2391cb0ef41Sopenharmony_ci /* Points to the oldest idle stream. NULL if there is no idle 2401cb0ef41Sopenharmony_ci stream. Only used when session is initialized as erver. */ 2411cb0ef41Sopenharmony_ci nghttp2_stream *idle_stream_tail; 2421cb0ef41Sopenharmony_ci /* Queue of In-flight SETTINGS values. SETTINGS bearing ACK is not 2431cb0ef41Sopenharmony_ci considered as in-flight. */ 2441cb0ef41Sopenharmony_ci nghttp2_inflight_settings *inflight_settings_head; 2451cb0ef41Sopenharmony_ci /* Stream reset rate limiter. If receiving excessive amount of 2461cb0ef41Sopenharmony_ci stream resets, GOAWAY will be sent. */ 2471cb0ef41Sopenharmony_ci nghttp2_ratelim stream_reset_ratelim; 2481cb0ef41Sopenharmony_ci /* Sequential number across all streams to process streams in 2491cb0ef41Sopenharmony_ci FIFO. */ 2501cb0ef41Sopenharmony_ci uint64_t stream_seq; 2511cb0ef41Sopenharmony_ci /* The number of outgoing streams. This will be capped by 2521cb0ef41Sopenharmony_ci remote_settings.max_concurrent_streams. */ 2531cb0ef41Sopenharmony_ci size_t num_outgoing_streams; 2541cb0ef41Sopenharmony_ci /* The number of incoming streams. This will be capped by 2551cb0ef41Sopenharmony_ci local_settings.max_concurrent_streams. */ 2561cb0ef41Sopenharmony_ci size_t num_incoming_streams; 2571cb0ef41Sopenharmony_ci /* The number of incoming reserved streams. This is the number of 2581cb0ef41Sopenharmony_ci streams in reserved (remote) state. RFC 7540 does not limit this 2591cb0ef41Sopenharmony_ci number. nghttp2 offers 2601cb0ef41Sopenharmony_ci nghttp2_option_set_max_reserved_remote_streams() to achieve this. 2611cb0ef41Sopenharmony_ci If it is used, num_incoming_streams is capped by 2621cb0ef41Sopenharmony_ci max_incoming_reserved_streams. Client application should 2631cb0ef41Sopenharmony_ci consider to set this because without that server can send 2641cb0ef41Sopenharmony_ci arbitrary number of PUSH_PROMISE, and exhaust client's memory. */ 2651cb0ef41Sopenharmony_ci size_t num_incoming_reserved_streams; 2661cb0ef41Sopenharmony_ci /* The maximum number of incoming reserved streams (reserved 2671cb0ef41Sopenharmony_ci (remote) state). RST_STREAM will be sent for the pushed stream 2681cb0ef41Sopenharmony_ci which exceeds this limit. */ 2691cb0ef41Sopenharmony_ci size_t max_incoming_reserved_streams; 2701cb0ef41Sopenharmony_ci /* The number of closed streams still kept in |streams| hash. The 2711cb0ef41Sopenharmony_ci closed streams can be accessed through single linked list 2721cb0ef41Sopenharmony_ci |closed_stream_head|. The current implementation only keeps 2731cb0ef41Sopenharmony_ci incoming streams and session is initialized as server. */ 2741cb0ef41Sopenharmony_ci size_t num_closed_streams; 2751cb0ef41Sopenharmony_ci /* The number of idle streams kept in |streams| hash. The idle 2761cb0ef41Sopenharmony_ci streams can be accessed through doubly linked list 2771cb0ef41Sopenharmony_ci |idle_stream_head|. The current implementation only keeps idle 2781cb0ef41Sopenharmony_ci streams if session is initialized as server. */ 2791cb0ef41Sopenharmony_ci size_t num_idle_streams; 2801cb0ef41Sopenharmony_ci /* The number of bytes allocated for nvbuf */ 2811cb0ef41Sopenharmony_ci size_t nvbuflen; 2821cb0ef41Sopenharmony_ci /* Counter for detecting flooding in outbound queue. If it exceeds 2831cb0ef41Sopenharmony_ci max_outbound_ack, session will be closed. */ 2841cb0ef41Sopenharmony_ci size_t obq_flood_counter_; 2851cb0ef41Sopenharmony_ci /* The maximum number of outgoing SETTINGS ACK and PING ACK in 2861cb0ef41Sopenharmony_ci outbound queue. */ 2871cb0ef41Sopenharmony_ci size_t max_outbound_ack; 2881cb0ef41Sopenharmony_ci /* The maximum length of header block to send. Calculated by the 2891cb0ef41Sopenharmony_ci same way as nghttp2_hd_deflate_bound() does. */ 2901cb0ef41Sopenharmony_ci size_t max_send_header_block_length; 2911cb0ef41Sopenharmony_ci /* The maximum number of settings accepted per SETTINGS frame. */ 2921cb0ef41Sopenharmony_ci size_t max_settings; 2931cb0ef41Sopenharmony_ci /* Next Stream ID. Made unsigned int to detect >= (1 << 31). */ 2941cb0ef41Sopenharmony_ci uint32_t next_stream_id; 2951cb0ef41Sopenharmony_ci /* The last stream ID this session initiated. For client session, 2961cb0ef41Sopenharmony_ci this is the last stream ID it has sent. For server session, it 2971cb0ef41Sopenharmony_ci is the last promised stream ID sent in PUSH_PROMISE. */ 2981cb0ef41Sopenharmony_ci int32_t last_sent_stream_id; 2991cb0ef41Sopenharmony_ci /* The largest stream ID received so far */ 3001cb0ef41Sopenharmony_ci int32_t last_recv_stream_id; 3011cb0ef41Sopenharmony_ci /* The largest stream ID which has been processed in some way. This 3021cb0ef41Sopenharmony_ci value will be used as last-stream-id when sending GOAWAY 3031cb0ef41Sopenharmony_ci frame. */ 3041cb0ef41Sopenharmony_ci int32_t last_proc_stream_id; 3051cb0ef41Sopenharmony_ci /* Counter of unique ID of PING. Wraps when it exceeds 3061cb0ef41Sopenharmony_ci NGHTTP2_MAX_UNIQUE_ID */ 3071cb0ef41Sopenharmony_ci uint32_t next_unique_id; 3081cb0ef41Sopenharmony_ci /* This is the last-stream-ID we have sent in GOAWAY */ 3091cb0ef41Sopenharmony_ci int32_t local_last_stream_id; 3101cb0ef41Sopenharmony_ci /* This is the value in GOAWAY frame received from remote endpoint. */ 3111cb0ef41Sopenharmony_ci int32_t remote_last_stream_id; 3121cb0ef41Sopenharmony_ci /* Current sender window size. This value is computed against the 3131cb0ef41Sopenharmony_ci current initial window size of remote endpoint. */ 3141cb0ef41Sopenharmony_ci int32_t remote_window_size; 3151cb0ef41Sopenharmony_ci /* Keep track of the number of bytes received without 3161cb0ef41Sopenharmony_ci WINDOW_UPDATE. This could be negative after submitting negative 3171cb0ef41Sopenharmony_ci value to WINDOW_UPDATE. */ 3181cb0ef41Sopenharmony_ci int32_t recv_window_size; 3191cb0ef41Sopenharmony_ci /* The number of bytes consumed by the application and now is 3201cb0ef41Sopenharmony_ci subject to WINDOW_UPDATE. This is only used when auto 3211cb0ef41Sopenharmony_ci WINDOW_UPDATE is turned off. */ 3221cb0ef41Sopenharmony_ci int32_t consumed_size; 3231cb0ef41Sopenharmony_ci /* The amount of recv_window_size cut using submitting negative 3241cb0ef41Sopenharmony_ci value to WINDOW_UPDATE */ 3251cb0ef41Sopenharmony_ci int32_t recv_reduction; 3261cb0ef41Sopenharmony_ci /* window size for local flow control. It is initially set to 3271cb0ef41Sopenharmony_ci NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE and could be 3281cb0ef41Sopenharmony_ci increased/decreased by submitting WINDOW_UPDATE. See 3291cb0ef41Sopenharmony_ci nghttp2_submit_window_update(). */ 3301cb0ef41Sopenharmony_ci int32_t local_window_size; 3311cb0ef41Sopenharmony_ci /* This flag is used to indicate that the local endpoint received initial 3321cb0ef41Sopenharmony_ci SETTINGS frame from the remote endpoint. */ 3331cb0ef41Sopenharmony_ci uint8_t remote_settings_received; 3341cb0ef41Sopenharmony_ci /* Settings value received from the remote endpoint. */ 3351cb0ef41Sopenharmony_ci nghttp2_settings_storage remote_settings; 3361cb0ef41Sopenharmony_ci /* Settings value of the local endpoint. */ 3371cb0ef41Sopenharmony_ci nghttp2_settings_storage local_settings; 3381cb0ef41Sopenharmony_ci /* Option flags. This is bitwise-OR of 0 or more of nghttp2_optmask. */ 3391cb0ef41Sopenharmony_ci uint32_t opt_flags; 3401cb0ef41Sopenharmony_ci /* Unacked local SETTINGS_MAX_CONCURRENT_STREAMS value. We use this 3411cb0ef41Sopenharmony_ci to refuse the incoming stream if it exceeds this value. */ 3421cb0ef41Sopenharmony_ci uint32_t pending_local_max_concurrent_stream; 3431cb0ef41Sopenharmony_ci /* The bitwise OR of zero or more of nghttp2_typemask to indicate 3441cb0ef41Sopenharmony_ci that the default handling of extension frame is enabled. */ 3451cb0ef41Sopenharmony_ci uint32_t builtin_recv_ext_types; 3461cb0ef41Sopenharmony_ci /* Unacked local ENABLE_PUSH value. We use this to refuse 3471cb0ef41Sopenharmony_ci PUSH_PROMISE before SETTINGS ACK is received. */ 3481cb0ef41Sopenharmony_ci uint8_t pending_enable_push; 3491cb0ef41Sopenharmony_ci /* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to 3501cb0ef41Sopenharmony_ci accept :protocol header field before SETTINGS_ACK is received. */ 3511cb0ef41Sopenharmony_ci uint8_t pending_enable_connect_protocol; 3521cb0ef41Sopenharmony_ci /* Unacked local SETTINGS_NO_RFC7540_PRIORITIES value, which is 3531cb0ef41Sopenharmony_ci effective before it is acknowledged. */ 3541cb0ef41Sopenharmony_ci uint8_t pending_no_rfc7540_priorities; 3551cb0ef41Sopenharmony_ci /* Turn on fallback to RFC 7540 priorities; for server use only. */ 3561cb0ef41Sopenharmony_ci uint8_t fallback_rfc7540_priorities; 3571cb0ef41Sopenharmony_ci /* Nonzero if the session is server side. */ 3581cb0ef41Sopenharmony_ci uint8_t server; 3591cb0ef41Sopenharmony_ci /* Flags indicating GOAWAY is sent and/or received. The flags are 3601cb0ef41Sopenharmony_ci composed by bitwise OR-ing nghttp2_goaway_flag. */ 3611cb0ef41Sopenharmony_ci uint8_t goaway_flags; 3621cb0ef41Sopenharmony_ci /* This flag is used to reduce excessive queuing of WINDOW_UPDATE to 3631cb0ef41Sopenharmony_ci this session. The nonzero does not necessarily mean 3641cb0ef41Sopenharmony_ci WINDOW_UPDATE is not queued. */ 3651cb0ef41Sopenharmony_ci uint8_t window_update_queued; 3661cb0ef41Sopenharmony_ci /* Bitfield of extension frame types that application is willing to 3671cb0ef41Sopenharmony_ci receive. To designate the bit of given frame type i, use 3681cb0ef41Sopenharmony_ci user_recv_ext_types[i / 8] & (1 << (i & 0x7)). First 10 frame 3691cb0ef41Sopenharmony_ci types are standard frame types and not used in this bitfield. If 3701cb0ef41Sopenharmony_ci bit is set, it indicates that incoming frame with that type is 3711cb0ef41Sopenharmony_ci passed to user defined callbacks, otherwise they are ignored. */ 3721cb0ef41Sopenharmony_ci uint8_t user_recv_ext_types[32]; 3731cb0ef41Sopenharmony_ci}; 3741cb0ef41Sopenharmony_ci 3751cb0ef41Sopenharmony_ci/* Struct used when updating initial window size of each active 3761cb0ef41Sopenharmony_ci stream. */ 3771cb0ef41Sopenharmony_citypedef struct { 3781cb0ef41Sopenharmony_ci nghttp2_session *session; 3791cb0ef41Sopenharmony_ci int32_t new_window_size, old_window_size; 3801cb0ef41Sopenharmony_ci} nghttp2_update_window_size_arg; 3811cb0ef41Sopenharmony_ci 3821cb0ef41Sopenharmony_citypedef struct { 3831cb0ef41Sopenharmony_ci nghttp2_session *session; 3841cb0ef41Sopenharmony_ci /* linked list of streams to close */ 3851cb0ef41Sopenharmony_ci nghttp2_stream *head; 3861cb0ef41Sopenharmony_ci int32_t last_stream_id; 3871cb0ef41Sopenharmony_ci /* nonzero if GOAWAY is sent to peer, which means we are going to 3881cb0ef41Sopenharmony_ci close incoming streams. zero if GOAWAY is received from peer and 3891cb0ef41Sopenharmony_ci we are going to close outgoing streams. */ 3901cb0ef41Sopenharmony_ci int incoming; 3911cb0ef41Sopenharmony_ci} nghttp2_close_stream_on_goaway_arg; 3921cb0ef41Sopenharmony_ci 3931cb0ef41Sopenharmony_ci/* TODO stream timeout etc */ 3941cb0ef41Sopenharmony_ci 3951cb0ef41Sopenharmony_ci/* 3961cb0ef41Sopenharmony_ci * Returns nonzero value if |stream_id| is initiated by local 3971cb0ef41Sopenharmony_ci * endpoint. 3981cb0ef41Sopenharmony_ci */ 3991cb0ef41Sopenharmony_ciint nghttp2_session_is_my_stream_id(nghttp2_session *session, 4001cb0ef41Sopenharmony_ci int32_t stream_id); 4011cb0ef41Sopenharmony_ci 4021cb0ef41Sopenharmony_ci/* 4031cb0ef41Sopenharmony_ci * Adds |item| to the outbound queue in |session|. When this function 4041cb0ef41Sopenharmony_ci * succeeds, it takes ownership of |item|. So caller must not free it 4051cb0ef41Sopenharmony_ci * on success. 4061cb0ef41Sopenharmony_ci * 4071cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4081cb0ef41Sopenharmony_ci * negative error codes: 4091cb0ef41Sopenharmony_ci * 4101cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4111cb0ef41Sopenharmony_ci * Out of memory. 4121cb0ef41Sopenharmony_ci * NGHTTP2_ERR_STREAM_CLOSED 4131cb0ef41Sopenharmony_ci * Stream already closed (DATA and PUSH_PROMISE frame only) 4141cb0ef41Sopenharmony_ci */ 4151cb0ef41Sopenharmony_ciint nghttp2_session_add_item(nghttp2_session *session, 4161cb0ef41Sopenharmony_ci nghttp2_outbound_item *item); 4171cb0ef41Sopenharmony_ci 4181cb0ef41Sopenharmony_ci/* 4191cb0ef41Sopenharmony_ci * Adds RST_STREAM frame for the stream |stream_id| with the error 4201cb0ef41Sopenharmony_ci * code |error_code|. This is a convenient function built on top of 4211cb0ef41Sopenharmony_ci * nghttp2_session_add_frame() to add RST_STREAM easily. 4221cb0ef41Sopenharmony_ci * 4231cb0ef41Sopenharmony_ci * This function simply returns 0 without adding RST_STREAM frame if 4241cb0ef41Sopenharmony_ci * given stream is in NGHTTP2_STREAM_CLOSING state, because multiple 4251cb0ef41Sopenharmony_ci * RST_STREAM for a stream is redundant. 4261cb0ef41Sopenharmony_ci * 4271cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4281cb0ef41Sopenharmony_ci * negative error codes: 4291cb0ef41Sopenharmony_ci * 4301cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4311cb0ef41Sopenharmony_ci * Out of memory. 4321cb0ef41Sopenharmony_ci */ 4331cb0ef41Sopenharmony_ciint nghttp2_session_add_rst_stream(nghttp2_session *session, int32_t stream_id, 4341cb0ef41Sopenharmony_ci uint32_t error_code); 4351cb0ef41Sopenharmony_ci 4361cb0ef41Sopenharmony_ci/* 4371cb0ef41Sopenharmony_ci * Adds PING frame. This is a convenient function built on top of 4381cb0ef41Sopenharmony_ci * nghttp2_session_add_frame() to add PING easily. 4391cb0ef41Sopenharmony_ci * 4401cb0ef41Sopenharmony_ci * If the |opaque_data| is not NULL, it must point to 8 bytes memory 4411cb0ef41Sopenharmony_ci * region of data. The data pointed by |opaque_data| is copied. It can 4421cb0ef41Sopenharmony_ci * be NULL. In this case, 8 bytes NULL is used. 4431cb0ef41Sopenharmony_ci * 4441cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4451cb0ef41Sopenharmony_ci * negative error codes: 4461cb0ef41Sopenharmony_ci * 4471cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4481cb0ef41Sopenharmony_ci * Out of memory. 4491cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FLOODED 4501cb0ef41Sopenharmony_ci * There are too many items in outbound queue; this only happens 4511cb0ef41Sopenharmony_ci * if NGHTTP2_FLAG_ACK is set in |flags| 4521cb0ef41Sopenharmony_ci */ 4531cb0ef41Sopenharmony_ciint nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags, 4541cb0ef41Sopenharmony_ci const uint8_t *opaque_data); 4551cb0ef41Sopenharmony_ci 4561cb0ef41Sopenharmony_ci/* 4571cb0ef41Sopenharmony_ci * Adds GOAWAY frame with the last-stream-ID |last_stream_id| and the 4581cb0ef41Sopenharmony_ci * error code |error_code|. This is a convenient function built on top 4591cb0ef41Sopenharmony_ci * of nghttp2_session_add_frame() to add GOAWAY easily. The 4601cb0ef41Sopenharmony_ci * |aux_flags| are bitwise-OR of one or more of 4611cb0ef41Sopenharmony_ci * nghttp2_goaway_aux_flag. 4621cb0ef41Sopenharmony_ci * 4631cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4641cb0ef41Sopenharmony_ci * negative error codes: 4651cb0ef41Sopenharmony_ci * 4661cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4671cb0ef41Sopenharmony_ci * Out of memory. 4681cb0ef41Sopenharmony_ci * NGHTTP2_ERR_INVALID_ARGUMENT 4691cb0ef41Sopenharmony_ci * The |opaque_data_len| is too large. 4701cb0ef41Sopenharmony_ci */ 4711cb0ef41Sopenharmony_ciint nghttp2_session_add_goaway(nghttp2_session *session, int32_t last_stream_id, 4721cb0ef41Sopenharmony_ci uint32_t error_code, const uint8_t *opaque_data, 4731cb0ef41Sopenharmony_ci size_t opaque_data_len, uint8_t aux_flags); 4741cb0ef41Sopenharmony_ci 4751cb0ef41Sopenharmony_ci/* 4761cb0ef41Sopenharmony_ci * Adds WINDOW_UPDATE frame with stream ID |stream_id| and 4771cb0ef41Sopenharmony_ci * window-size-increment |window_size_increment|. This is a convenient 4781cb0ef41Sopenharmony_ci * function built on top of nghttp2_session_add_frame() to add 4791cb0ef41Sopenharmony_ci * WINDOW_UPDATE easily. 4801cb0ef41Sopenharmony_ci * 4811cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4821cb0ef41Sopenharmony_ci * negative error codes: 4831cb0ef41Sopenharmony_ci * 4841cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4851cb0ef41Sopenharmony_ci * Out of memory. 4861cb0ef41Sopenharmony_ci */ 4871cb0ef41Sopenharmony_ciint nghttp2_session_add_window_update(nghttp2_session *session, uint8_t flags, 4881cb0ef41Sopenharmony_ci int32_t stream_id, 4891cb0ef41Sopenharmony_ci int32_t window_size_increment); 4901cb0ef41Sopenharmony_ci 4911cb0ef41Sopenharmony_ci/* 4921cb0ef41Sopenharmony_ci * Adds SETTINGS frame. 4931cb0ef41Sopenharmony_ci * 4941cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 4951cb0ef41Sopenharmony_ci * negative error codes: 4961cb0ef41Sopenharmony_ci * 4971cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4981cb0ef41Sopenharmony_ci * Out of memory. 4991cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FLOODED 5001cb0ef41Sopenharmony_ci * There are too many items in outbound queue; this only happens 5011cb0ef41Sopenharmony_ci * if NGHTTP2_FLAG_ACK is set in |flags| 5021cb0ef41Sopenharmony_ci */ 5031cb0ef41Sopenharmony_ciint nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags, 5041cb0ef41Sopenharmony_ci const nghttp2_settings_entry *iv, size_t niv); 5051cb0ef41Sopenharmony_ci 5061cb0ef41Sopenharmony_ci/* 5071cb0ef41Sopenharmony_ci * Creates new stream in |session| with stream ID |stream_id|, 5081cb0ef41Sopenharmony_ci * priority |pri_spec| and flags |flags|. The |flags| is bitwise OR 5091cb0ef41Sopenharmony_ci * of nghttp2_stream_flag. Since this function is called when initial 5101cb0ef41Sopenharmony_ci * HEADERS is sent or received, these flags are taken from it. The 5111cb0ef41Sopenharmony_ci * state of stream is set to |initial_state|. The |stream_user_data| 5121cb0ef41Sopenharmony_ci * is a pointer to the arbitrary user supplied data to be associated 5131cb0ef41Sopenharmony_ci * to this stream. 5141cb0ef41Sopenharmony_ci * 5151cb0ef41Sopenharmony_ci * If |initial_state| is NGHTTP2_STREAM_RESERVED, this function sets 5161cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_FLAG_PUSH flag set. 5171cb0ef41Sopenharmony_ci * 5181cb0ef41Sopenharmony_ci * This function returns a pointer to created new stream object, or 5191cb0ef41Sopenharmony_ci * NULL. 5201cb0ef41Sopenharmony_ci * 5211cb0ef41Sopenharmony_ci * This function adjusts neither the number of closed streams or idle 5221cb0ef41Sopenharmony_ci * streams. The caller should manually call 5231cb0ef41Sopenharmony_ci * nghttp2_session_adjust_closed_stream() or 5241cb0ef41Sopenharmony_ci * nghttp2_session_adjust_idle_stream() respectively. 5251cb0ef41Sopenharmony_ci */ 5261cb0ef41Sopenharmony_cinghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session, 5271cb0ef41Sopenharmony_ci int32_t stream_id, uint8_t flags, 5281cb0ef41Sopenharmony_ci nghttp2_priority_spec *pri_spec, 5291cb0ef41Sopenharmony_ci nghttp2_stream_state initial_state, 5301cb0ef41Sopenharmony_ci void *stream_user_data); 5311cb0ef41Sopenharmony_ci 5321cb0ef41Sopenharmony_ci/* 5331cb0ef41Sopenharmony_ci * Closes stream whose stream ID is |stream_id|. The reason of closure 5341cb0ef41Sopenharmony_ci * is indicated by the |error_code|. When closing the stream, 5351cb0ef41Sopenharmony_ci * on_stream_close_callback will be called. 5361cb0ef41Sopenharmony_ci * 5371cb0ef41Sopenharmony_ci * If the session is initialized as server and |stream| is incoming 5381cb0ef41Sopenharmony_ci * stream, stream is just marked closed and this function calls 5391cb0ef41Sopenharmony_ci * nghttp2_session_keep_closed_stream() with |stream|. Otherwise, 5401cb0ef41Sopenharmony_ci * |stream| will be deleted from memory. 5411cb0ef41Sopenharmony_ci * 5421cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 5431cb0ef41Sopenharmony_ci * negative error codes: 5441cb0ef41Sopenharmony_ci * 5451cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 5461cb0ef41Sopenharmony_ci * Out of memory 5471cb0ef41Sopenharmony_ci * NGHTTP2_ERR_INVALID_ARGUMENT 5481cb0ef41Sopenharmony_ci * The specified stream does not exist. 5491cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 5501cb0ef41Sopenharmony_ci * The callback function failed. 5511cb0ef41Sopenharmony_ci */ 5521cb0ef41Sopenharmony_ciint nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id, 5531cb0ef41Sopenharmony_ci uint32_t error_code); 5541cb0ef41Sopenharmony_ci 5551cb0ef41Sopenharmony_ci/* 5561cb0ef41Sopenharmony_ci * Deletes |stream| from memory. After this function returns, stream 5571cb0ef41Sopenharmony_ci * cannot be accessed. 5581cb0ef41Sopenharmony_ci * 5591cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 5601cb0ef41Sopenharmony_ci * negative error codes: 5611cb0ef41Sopenharmony_ci * 5621cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 5631cb0ef41Sopenharmony_ci * Out of memory 5641cb0ef41Sopenharmony_ci */ 5651cb0ef41Sopenharmony_ciint nghttp2_session_destroy_stream(nghttp2_session *session, 5661cb0ef41Sopenharmony_ci nghttp2_stream *stream); 5671cb0ef41Sopenharmony_ci 5681cb0ef41Sopenharmony_ci/* 5691cb0ef41Sopenharmony_ci * Tries to keep incoming closed stream |stream|. Due to the 5701cb0ef41Sopenharmony_ci * limitation of maximum number of streams in memory, |stream| is not 5711cb0ef41Sopenharmony_ci * closed and just deleted from memory (see 5721cb0ef41Sopenharmony_ci * nghttp2_session_destroy_stream). 5731cb0ef41Sopenharmony_ci */ 5741cb0ef41Sopenharmony_civoid nghttp2_session_keep_closed_stream(nghttp2_session *session, 5751cb0ef41Sopenharmony_ci nghttp2_stream *stream); 5761cb0ef41Sopenharmony_ci 5771cb0ef41Sopenharmony_ci/* 5781cb0ef41Sopenharmony_ci * Appends |stream| to linked list |session->idle_stream_head|. We 5791cb0ef41Sopenharmony_ci * apply fixed limit for list size. To fit into that limit, one or 5801cb0ef41Sopenharmony_ci * more oldest streams are removed from list as necessary. 5811cb0ef41Sopenharmony_ci */ 5821cb0ef41Sopenharmony_civoid nghttp2_session_keep_idle_stream(nghttp2_session *session, 5831cb0ef41Sopenharmony_ci nghttp2_stream *stream); 5841cb0ef41Sopenharmony_ci 5851cb0ef41Sopenharmony_ci/* 5861cb0ef41Sopenharmony_ci * Detaches |stream| from idle streams linked list. 5871cb0ef41Sopenharmony_ci */ 5881cb0ef41Sopenharmony_civoid nghttp2_session_detach_idle_stream(nghttp2_session *session, 5891cb0ef41Sopenharmony_ci nghttp2_stream *stream); 5901cb0ef41Sopenharmony_ci 5911cb0ef41Sopenharmony_ci/* 5921cb0ef41Sopenharmony_ci * Deletes closed stream to ensure that number of incoming streams 5931cb0ef41Sopenharmony_ci * including active and closed is in the maximum number of allowed 5941cb0ef41Sopenharmony_ci * stream. 5951cb0ef41Sopenharmony_ci * 5961cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 5971cb0ef41Sopenharmony_ci * negative error codes: 5981cb0ef41Sopenharmony_ci * 5991cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6001cb0ef41Sopenharmony_ci * Out of memory 6011cb0ef41Sopenharmony_ci */ 6021cb0ef41Sopenharmony_ciint nghttp2_session_adjust_closed_stream(nghttp2_session *session); 6031cb0ef41Sopenharmony_ci 6041cb0ef41Sopenharmony_ci/* 6051cb0ef41Sopenharmony_ci * Deletes idle stream to ensure that number of idle streams is in 6061cb0ef41Sopenharmony_ci * certain limit. 6071cb0ef41Sopenharmony_ci * 6081cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 6091cb0ef41Sopenharmony_ci * negative error codes: 6101cb0ef41Sopenharmony_ci * 6111cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6121cb0ef41Sopenharmony_ci * Out of memory 6131cb0ef41Sopenharmony_ci */ 6141cb0ef41Sopenharmony_ciint nghttp2_session_adjust_idle_stream(nghttp2_session *session); 6151cb0ef41Sopenharmony_ci 6161cb0ef41Sopenharmony_ci/* 6171cb0ef41Sopenharmony_ci * If further receptions and transmissions over the stream |stream_id| 6181cb0ef41Sopenharmony_ci * are disallowed, close the stream with error code NGHTTP2_NO_ERROR. 6191cb0ef41Sopenharmony_ci * 6201cb0ef41Sopenharmony_ci * This function returns 0 if it 6211cb0ef41Sopenharmony_ci * succeeds, or one of the following negative error codes: 6221cb0ef41Sopenharmony_ci * 6231cb0ef41Sopenharmony_ci * NGHTTP2_ERR_INVALID_ARGUMENT 6241cb0ef41Sopenharmony_ci * The specified stream does not exist. 6251cb0ef41Sopenharmony_ci */ 6261cb0ef41Sopenharmony_ciint nghttp2_session_close_stream_if_shut_rdwr(nghttp2_session *session, 6271cb0ef41Sopenharmony_ci nghttp2_stream *stream); 6281cb0ef41Sopenharmony_ci 6291cb0ef41Sopenharmony_ciint nghttp2_session_on_request_headers_received(nghttp2_session *session, 6301cb0ef41Sopenharmony_ci nghttp2_frame *frame); 6311cb0ef41Sopenharmony_ci 6321cb0ef41Sopenharmony_ciint nghttp2_session_on_response_headers_received(nghttp2_session *session, 6331cb0ef41Sopenharmony_ci nghttp2_frame *frame, 6341cb0ef41Sopenharmony_ci nghttp2_stream *stream); 6351cb0ef41Sopenharmony_ci 6361cb0ef41Sopenharmony_ciint nghttp2_session_on_push_response_headers_received(nghttp2_session *session, 6371cb0ef41Sopenharmony_ci nghttp2_frame *frame, 6381cb0ef41Sopenharmony_ci nghttp2_stream *stream); 6391cb0ef41Sopenharmony_ci 6401cb0ef41Sopenharmony_ci/* 6411cb0ef41Sopenharmony_ci * Called when HEADERS is received, assuming |frame| is properly 6421cb0ef41Sopenharmony_ci * initialized. This function does first validate received frame and 6431cb0ef41Sopenharmony_ci * then open stream and call callback functions. 6441cb0ef41Sopenharmony_ci * 6451cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 6461cb0ef41Sopenharmony_ci * negative error codes: 6471cb0ef41Sopenharmony_ci * 6481cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6491cb0ef41Sopenharmony_ci * Out of memory. 6501cb0ef41Sopenharmony_ci * NGHTTP2_ERR_IGN_HEADER_BLOCK 6511cb0ef41Sopenharmony_ci * Frame was rejected and header block must be decoded but 6521cb0ef41Sopenharmony_ci * result must be ignored. 6531cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 6541cb0ef41Sopenharmony_ci * The read_callback failed 6551cb0ef41Sopenharmony_ci */ 6561cb0ef41Sopenharmony_ciint nghttp2_session_on_headers_received(nghttp2_session *session, 6571cb0ef41Sopenharmony_ci nghttp2_frame *frame, 6581cb0ef41Sopenharmony_ci nghttp2_stream *stream); 6591cb0ef41Sopenharmony_ci 6601cb0ef41Sopenharmony_ci/* 6611cb0ef41Sopenharmony_ci * Called when PRIORITY is received, assuming |frame| is properly 6621cb0ef41Sopenharmony_ci * initialized. 6631cb0ef41Sopenharmony_ci * 6641cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 6651cb0ef41Sopenharmony_ci * negative error codes: 6661cb0ef41Sopenharmony_ci * 6671cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6681cb0ef41Sopenharmony_ci * Out of memory. 6691cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 6701cb0ef41Sopenharmony_ci * The read_callback failed 6711cb0ef41Sopenharmony_ci */ 6721cb0ef41Sopenharmony_ciint nghttp2_session_on_priority_received(nghttp2_session *session, 6731cb0ef41Sopenharmony_ci nghttp2_frame *frame); 6741cb0ef41Sopenharmony_ci 6751cb0ef41Sopenharmony_ci/* 6761cb0ef41Sopenharmony_ci * Called when RST_STREAM is received, assuming |frame| is properly 6771cb0ef41Sopenharmony_ci * initialized. 6781cb0ef41Sopenharmony_ci * 6791cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 6801cb0ef41Sopenharmony_ci * negative error codes: 6811cb0ef41Sopenharmony_ci * 6821cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6831cb0ef41Sopenharmony_ci * Out of memory 6841cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 6851cb0ef41Sopenharmony_ci * The read_callback failed 6861cb0ef41Sopenharmony_ci */ 6871cb0ef41Sopenharmony_ciint nghttp2_session_on_rst_stream_received(nghttp2_session *session, 6881cb0ef41Sopenharmony_ci nghttp2_frame *frame); 6891cb0ef41Sopenharmony_ci 6901cb0ef41Sopenharmony_ci/* 6911cb0ef41Sopenharmony_ci * Called when SETTINGS is received, assuming |frame| is properly 6921cb0ef41Sopenharmony_ci * initialized. If |noack| is non-zero, SETTINGS with ACK will not be 6931cb0ef41Sopenharmony_ci * submitted. If |frame| has NGHTTP2_FLAG_ACK flag set, no SETTINGS 6941cb0ef41Sopenharmony_ci * with ACK will not be submitted regardless of |noack|. 6951cb0ef41Sopenharmony_ci * 6961cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one the following 6971cb0ef41Sopenharmony_ci * negative error codes: 6981cb0ef41Sopenharmony_ci * 6991cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 7001cb0ef41Sopenharmony_ci * Out of memory 7011cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7021cb0ef41Sopenharmony_ci * The read_callback failed 7031cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FLOODED 7041cb0ef41Sopenharmony_ci * There are too many items in outbound queue, and this is most 7051cb0ef41Sopenharmony_ci * likely caused by misbehaviour of peer. 7061cb0ef41Sopenharmony_ci */ 7071cb0ef41Sopenharmony_ciint nghttp2_session_on_settings_received(nghttp2_session *session, 7081cb0ef41Sopenharmony_ci nghttp2_frame *frame, int noack); 7091cb0ef41Sopenharmony_ci 7101cb0ef41Sopenharmony_ci/* 7111cb0ef41Sopenharmony_ci * Called when PUSH_PROMISE is received, assuming |frame| is properly 7121cb0ef41Sopenharmony_ci * initialized. 7131cb0ef41Sopenharmony_ci * 7141cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7151cb0ef41Sopenharmony_ci * negative error codes: 7161cb0ef41Sopenharmony_ci * 7171cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 7181cb0ef41Sopenharmony_ci * Out of memory. 7191cb0ef41Sopenharmony_ci * NGHTTP2_ERR_IGN_HEADER_BLOCK 7201cb0ef41Sopenharmony_ci * Frame was rejected and header block must be decoded but 7211cb0ef41Sopenharmony_ci * result must be ignored. 7221cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7231cb0ef41Sopenharmony_ci * The read_callback failed 7241cb0ef41Sopenharmony_ci */ 7251cb0ef41Sopenharmony_ciint nghttp2_session_on_push_promise_received(nghttp2_session *session, 7261cb0ef41Sopenharmony_ci nghttp2_frame *frame); 7271cb0ef41Sopenharmony_ci 7281cb0ef41Sopenharmony_ci/* 7291cb0ef41Sopenharmony_ci * Called when PING is received, assuming |frame| is properly 7301cb0ef41Sopenharmony_ci * initialized. 7311cb0ef41Sopenharmony_ci * 7321cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7331cb0ef41Sopenharmony_ci * negative error codes: 7341cb0ef41Sopenharmony_ci * 7351cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 7361cb0ef41Sopenharmony_ci * Out of memory. 7371cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7381cb0ef41Sopenharmony_ci * The callback function failed. 7391cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FLOODED 7401cb0ef41Sopenharmony_ci * There are too many items in outbound queue, and this is most 7411cb0ef41Sopenharmony_ci * likely caused by misbehaviour of peer. 7421cb0ef41Sopenharmony_ci */ 7431cb0ef41Sopenharmony_ciint nghttp2_session_on_ping_received(nghttp2_session *session, 7441cb0ef41Sopenharmony_ci nghttp2_frame *frame); 7451cb0ef41Sopenharmony_ci 7461cb0ef41Sopenharmony_ci/* 7471cb0ef41Sopenharmony_ci * Called when GOAWAY is received, assuming |frame| is properly 7481cb0ef41Sopenharmony_ci * initialized. 7491cb0ef41Sopenharmony_ci * 7501cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7511cb0ef41Sopenharmony_ci * negative error codes: 7521cb0ef41Sopenharmony_ci * 7531cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 7541cb0ef41Sopenharmony_ci * Out of memory. 7551cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7561cb0ef41Sopenharmony_ci * The callback function failed. 7571cb0ef41Sopenharmony_ci */ 7581cb0ef41Sopenharmony_ciint nghttp2_session_on_goaway_received(nghttp2_session *session, 7591cb0ef41Sopenharmony_ci nghttp2_frame *frame); 7601cb0ef41Sopenharmony_ci 7611cb0ef41Sopenharmony_ci/* 7621cb0ef41Sopenharmony_ci * Called when WINDOW_UPDATE is received, assuming |frame| is properly 7631cb0ef41Sopenharmony_ci * initialized. 7641cb0ef41Sopenharmony_ci * 7651cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7661cb0ef41Sopenharmony_ci * negative error codes: 7671cb0ef41Sopenharmony_ci * 7681cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 7691cb0ef41Sopenharmony_ci * Out of memory. 7701cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7711cb0ef41Sopenharmony_ci * The callback function failed. 7721cb0ef41Sopenharmony_ci */ 7731cb0ef41Sopenharmony_ciint nghttp2_session_on_window_update_received(nghttp2_session *session, 7741cb0ef41Sopenharmony_ci nghttp2_frame *frame); 7751cb0ef41Sopenharmony_ci 7761cb0ef41Sopenharmony_ci/* 7771cb0ef41Sopenharmony_ci * Called when ALTSVC is received, assuming |frame| is properly 7781cb0ef41Sopenharmony_ci * initialized. 7791cb0ef41Sopenharmony_ci * 7801cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7811cb0ef41Sopenharmony_ci * negative error codes: 7821cb0ef41Sopenharmony_ci * 7831cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7841cb0ef41Sopenharmony_ci * The callback function failed. 7851cb0ef41Sopenharmony_ci */ 7861cb0ef41Sopenharmony_ciint nghttp2_session_on_altsvc_received(nghttp2_session *session, 7871cb0ef41Sopenharmony_ci nghttp2_frame *frame); 7881cb0ef41Sopenharmony_ci 7891cb0ef41Sopenharmony_ci/* 7901cb0ef41Sopenharmony_ci * Called when ORIGIN is received, assuming |frame| is properly 7911cb0ef41Sopenharmony_ci * initialized. 7921cb0ef41Sopenharmony_ci * 7931cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 7941cb0ef41Sopenharmony_ci * negative error codes: 7951cb0ef41Sopenharmony_ci * 7961cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 7971cb0ef41Sopenharmony_ci * The callback function failed. 7981cb0ef41Sopenharmony_ci */ 7991cb0ef41Sopenharmony_ciint nghttp2_session_on_origin_received(nghttp2_session *session, 8001cb0ef41Sopenharmony_ci nghttp2_frame *frame); 8011cb0ef41Sopenharmony_ci 8021cb0ef41Sopenharmony_ci/* 8031cb0ef41Sopenharmony_ci * Called when PRIORITY_UPDATE is received, assuming |frame| is 8041cb0ef41Sopenharmony_ci * properly initialized. 8051cb0ef41Sopenharmony_ci * 8061cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 8071cb0ef41Sopenharmony_ci * negative error codes: 8081cb0ef41Sopenharmony_ci * 8091cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 8101cb0ef41Sopenharmony_ci * The callback function failed. 8111cb0ef41Sopenharmony_ci */ 8121cb0ef41Sopenharmony_ciint nghttp2_session_on_priority_update_received(nghttp2_session *session, 8131cb0ef41Sopenharmony_ci nghttp2_frame *frame); 8141cb0ef41Sopenharmony_ci 8151cb0ef41Sopenharmony_ci/* 8161cb0ef41Sopenharmony_ci * Called when DATA is received, assuming |frame| is properly 8171cb0ef41Sopenharmony_ci * initialized. 8181cb0ef41Sopenharmony_ci * 8191cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 8201cb0ef41Sopenharmony_ci * negative error codes: 8211cb0ef41Sopenharmony_ci * 8221cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 8231cb0ef41Sopenharmony_ci * Out of memory. 8241cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 8251cb0ef41Sopenharmony_ci * The callback function failed. 8261cb0ef41Sopenharmony_ci */ 8271cb0ef41Sopenharmony_ciint nghttp2_session_on_data_received(nghttp2_session *session, 8281cb0ef41Sopenharmony_ci nghttp2_frame *frame); 8291cb0ef41Sopenharmony_ci 8301cb0ef41Sopenharmony_ci/* 8311cb0ef41Sopenharmony_ci * Returns nghttp2_stream* object whose stream ID is |stream_id|. It 8321cb0ef41Sopenharmony_ci * could be NULL if such stream does not exist. This function returns 8331cb0ef41Sopenharmony_ci * NULL if stream is marked as closed. 8341cb0ef41Sopenharmony_ci */ 8351cb0ef41Sopenharmony_cinghttp2_stream *nghttp2_session_get_stream(nghttp2_session *session, 8361cb0ef41Sopenharmony_ci int32_t stream_id); 8371cb0ef41Sopenharmony_ci 8381cb0ef41Sopenharmony_ci/* 8391cb0ef41Sopenharmony_ci * This function behaves like nghttp2_session_get_stream(), but it 8401cb0ef41Sopenharmony_ci * returns stream object even if it is marked as closed or in 8411cb0ef41Sopenharmony_ci * NGHTTP2_STREAM_IDLE state. 8421cb0ef41Sopenharmony_ci */ 8431cb0ef41Sopenharmony_cinghttp2_stream *nghttp2_session_get_stream_raw(nghttp2_session *session, 8441cb0ef41Sopenharmony_ci int32_t stream_id); 8451cb0ef41Sopenharmony_ci 8461cb0ef41Sopenharmony_ci/* 8471cb0ef41Sopenharmony_ci * Packs DATA frame |frame| in wire frame format and stores it in 8481cb0ef41Sopenharmony_ci * |bufs|. Payload will be read using |aux_data->data_prd|. The 8491cb0ef41Sopenharmony_ci * length of payload is at most |datamax| bytes. 8501cb0ef41Sopenharmony_ci * 8511cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 8521cb0ef41Sopenharmony_ci * negative error codes: 8531cb0ef41Sopenharmony_ci * 8541cb0ef41Sopenharmony_ci * NGHTTP2_ERR_DEFERRED 8551cb0ef41Sopenharmony_ci * The DATA frame is postponed. 8561cb0ef41Sopenharmony_ci * NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE 8571cb0ef41Sopenharmony_ci * The read_callback failed (stream error). 8581cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 8591cb0ef41Sopenharmony_ci * Out of memory. 8601cb0ef41Sopenharmony_ci * NGHTTP2_ERR_CALLBACK_FAILURE 8611cb0ef41Sopenharmony_ci * The read_callback failed (session error). 8621cb0ef41Sopenharmony_ci */ 8631cb0ef41Sopenharmony_ciint nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs, 8641cb0ef41Sopenharmony_ci size_t datamax, nghttp2_frame *frame, 8651cb0ef41Sopenharmony_ci nghttp2_data_aux_data *aux_data, 8661cb0ef41Sopenharmony_ci nghttp2_stream *stream); 8671cb0ef41Sopenharmony_ci 8681cb0ef41Sopenharmony_ci/* 8691cb0ef41Sopenharmony_ci * Pops and returns next item to send. If there is no such item, 8701cb0ef41Sopenharmony_ci * returns NULL. This function takes into account max concurrent 8711cb0ef41Sopenharmony_ci * streams. That means if session->ob_syn has item and max concurrent 8721cb0ef41Sopenharmony_ci * streams is reached, the even if other queues contain items, then 8731cb0ef41Sopenharmony_ci * this function returns NULL. 8741cb0ef41Sopenharmony_ci */ 8751cb0ef41Sopenharmony_cinghttp2_outbound_item * 8761cb0ef41Sopenharmony_cinghttp2_session_pop_next_ob_item(nghttp2_session *session); 8771cb0ef41Sopenharmony_ci 8781cb0ef41Sopenharmony_ci/* 8791cb0ef41Sopenharmony_ci * Returns next item to send. If there is no such item, this function 8801cb0ef41Sopenharmony_ci * returns NULL. This function takes into account max concurrent 8811cb0ef41Sopenharmony_ci * streams. That means if session->ob_syn has item and max concurrent 8821cb0ef41Sopenharmony_ci * streams is reached, the even if other queues contain items, then 8831cb0ef41Sopenharmony_ci * this function returns NULL. 8841cb0ef41Sopenharmony_ci */ 8851cb0ef41Sopenharmony_cinghttp2_outbound_item * 8861cb0ef41Sopenharmony_cinghttp2_session_get_next_ob_item(nghttp2_session *session); 8871cb0ef41Sopenharmony_ci 8881cb0ef41Sopenharmony_ci/* 8891cb0ef41Sopenharmony_ci * Updates local settings with the |iv|. The number of elements in the 8901cb0ef41Sopenharmony_ci * array pointed by the |iv| is given by the |niv|. This function 8911cb0ef41Sopenharmony_ci * assumes that the all settings_id member in |iv| are in range 1 to 8921cb0ef41Sopenharmony_ci * NGHTTP2_SETTINGS_MAX, inclusive. 8931cb0ef41Sopenharmony_ci * 8941cb0ef41Sopenharmony_ci * While updating individual stream's local window size, if the window 8951cb0ef41Sopenharmony_ci * size becomes strictly larger than NGHTTP2_MAX_WINDOW_SIZE, 8961cb0ef41Sopenharmony_ci * RST_STREAM is issued against such a stream. 8971cb0ef41Sopenharmony_ci * 8981cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 8991cb0ef41Sopenharmony_ci * negative error codes: 9001cb0ef41Sopenharmony_ci * 9011cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 9021cb0ef41Sopenharmony_ci * Out of memory 9031cb0ef41Sopenharmony_ci */ 9041cb0ef41Sopenharmony_ciint nghttp2_session_update_local_settings(nghttp2_session *session, 9051cb0ef41Sopenharmony_ci nghttp2_settings_entry *iv, 9061cb0ef41Sopenharmony_ci size_t niv); 9071cb0ef41Sopenharmony_ci 9081cb0ef41Sopenharmony_ci/* 9091cb0ef41Sopenharmony_ci * Re-prioritize |stream|. The new priority specification is 9101cb0ef41Sopenharmony_ci * |pri_spec|. Caller must ensure that stream->hd.stream_id != 9111cb0ef41Sopenharmony_ci * pri_spec->stream_id. 9121cb0ef41Sopenharmony_ci * 9131cb0ef41Sopenharmony_ci * This function does not adjust the number of idle streams. The 9141cb0ef41Sopenharmony_ci * caller should call nghttp2_session_adjust_idle_stream() later. 9151cb0ef41Sopenharmony_ci * 9161cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 9171cb0ef41Sopenharmony_ci * negative error codes: 9181cb0ef41Sopenharmony_ci * 9191cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 9201cb0ef41Sopenharmony_ci * Out of memory 9211cb0ef41Sopenharmony_ci */ 9221cb0ef41Sopenharmony_ciint nghttp2_session_reprioritize_stream(nghttp2_session *session, 9231cb0ef41Sopenharmony_ci nghttp2_stream *stream, 9241cb0ef41Sopenharmony_ci const nghttp2_priority_spec *pri_spec); 9251cb0ef41Sopenharmony_ci 9261cb0ef41Sopenharmony_ci/* 9271cb0ef41Sopenharmony_ci * Terminates current |session| with the |error_code|. The |reason| 9281cb0ef41Sopenharmony_ci * is NULL-terminated debug string. 9291cb0ef41Sopenharmony_ci * 9301cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 9311cb0ef41Sopenharmony_ci * negative error codes: 9321cb0ef41Sopenharmony_ci * 9331cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 9341cb0ef41Sopenharmony_ci * Out of memory. 9351cb0ef41Sopenharmony_ci * NGHTTP2_ERR_INVALID_ARGUMENT 9361cb0ef41Sopenharmony_ci * The |reason| is too long. 9371cb0ef41Sopenharmony_ci */ 9381cb0ef41Sopenharmony_ciint nghttp2_session_terminate_session_with_reason(nghttp2_session *session, 9391cb0ef41Sopenharmony_ci uint32_t error_code, 9401cb0ef41Sopenharmony_ci const char *reason); 9411cb0ef41Sopenharmony_ci 9421cb0ef41Sopenharmony_ci/* 9431cb0ef41Sopenharmony_ci * Accumulates received bytes |delta_size| for connection-level flow 9441cb0ef41Sopenharmony_ci * control and decides whether to send WINDOW_UPDATE to the 9451cb0ef41Sopenharmony_ci * connection. If NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE is set, 9461cb0ef41Sopenharmony_ci * WINDOW_UPDATE will not be sent. 9471cb0ef41Sopenharmony_ci * 9481cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 9491cb0ef41Sopenharmony_ci * negative error codes: 9501cb0ef41Sopenharmony_ci * 9511cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 9521cb0ef41Sopenharmony_ci * Out of memory. 9531cb0ef41Sopenharmony_ci */ 9541cb0ef41Sopenharmony_ciint nghttp2_session_update_recv_connection_window_size(nghttp2_session *session, 9551cb0ef41Sopenharmony_ci size_t delta_size); 9561cb0ef41Sopenharmony_ci 9571cb0ef41Sopenharmony_ci/* 9581cb0ef41Sopenharmony_ci * Accumulates received bytes |delta_size| for stream-level flow 9591cb0ef41Sopenharmony_ci * control and decides whether to send WINDOW_UPDATE to that stream. 9601cb0ef41Sopenharmony_ci * If NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE is set, WINDOW_UPDATE will not 9611cb0ef41Sopenharmony_ci * be sent. 9621cb0ef41Sopenharmony_ci * 9631cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 9641cb0ef41Sopenharmony_ci * negative error codes: 9651cb0ef41Sopenharmony_ci * 9661cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 9671cb0ef41Sopenharmony_ci * Out of memory. 9681cb0ef41Sopenharmony_ci */ 9691cb0ef41Sopenharmony_ciint nghttp2_session_update_recv_stream_window_size(nghttp2_session *session, 9701cb0ef41Sopenharmony_ci nghttp2_stream *stream, 9711cb0ef41Sopenharmony_ci size_t delta_size, 9721cb0ef41Sopenharmony_ci int send_window_update); 9731cb0ef41Sopenharmony_ci 9741cb0ef41Sopenharmony_ci#endif /* NGHTTP2_SESSION_H */ 975