2012-01-24 14:02:24 +01:00
|
|
|
/*
|
2014-03-30 12:09:21 +02:00
|
|
|
* nghttp2 - HTTP/2 C Library
|
2012-01-24 14:02:24 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
#ifndef NGHTTP2_SESSION_H
|
|
|
|
#define NGHTTP2_SESSION_H
|
2012-01-24 14:02:24 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2018-06-09 09:21:30 +02:00
|
|
|
# include <config.h>
|
2012-01-24 14:02:24 +01:00
|
|
|
#endif /* HAVE_CONFIG_H */
|
|
|
|
|
2013-07-12 17:19:03 +02:00
|
|
|
#include <nghttp2/nghttp2.h>
|
|
|
|
#include "nghttp2_map.h"
|
|
|
|
#include "nghttp2_frame.h"
|
2013-07-19 17:08:14 +02:00
|
|
|
#include "nghttp2_hd.h"
|
2013-07-12 17:19:03 +02:00
|
|
|
#include "nghttp2_stream.h"
|
|
|
|
#include "nghttp2_outbound_item.h"
|
2014-01-26 07:44:43 +01:00
|
|
|
#include "nghttp2_int.h"
|
2014-03-10 17:47:38 +01:00
|
|
|
#include "nghttp2_buf.h"
|
2014-08-22 13:59:50 +02:00
|
|
|
#include "nghttp2_callbacks.h"
|
2014-12-07 15:07:13 +01:00
|
|
|
#include "nghttp2_mem.h"
|
2012-03-26 16:35:20 +02:00
|
|
|
|
2015-09-23 07:41:53 +02:00
|
|
|
/* The global variable for tests where we want to disable strict
|
|
|
|
preface handling. */
|
2015-10-21 17:57:00 +02:00
|
|
|
extern int nghttp2_enable_strict_preface;
|
2015-09-23 07:41:53 +02:00
|
|
|
|
2012-05-08 15:59:34 +02:00
|
|
|
/*
|
|
|
|
* Option flags.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
2014-07-25 14:26:03 +02:00
|
|
|
NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE = 1 << 0,
|
2015-04-05 15:35:40 +02:00
|
|
|
NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC = 1 << 1,
|
2016-02-29 15:39:50 +01:00
|
|
|
NGHTTP2_OPTMASK_NO_HTTP_MESSAGING = 1 << 2,
|
2017-02-13 14:15:42 +01:00
|
|
|
NGHTTP2_OPTMASK_NO_AUTO_PING_ACK = 1 << 3,
|
|
|
|
NGHTTP2_OPTMASK_NO_CLOSED_STREAMS = 1 << 4
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_optmask;
|
2012-05-08 15:59:34 +02:00
|
|
|
|
2016-04-09 11:23:15 +02:00
|
|
|
/*
|
|
|
|
* bitmask for built-in type to enable the default handling for that
|
|
|
|
* type of the frame.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
NGHTTP2_TYPEMASK_NONE = 0,
|
2018-05-10 03:57:02 +02:00
|
|
|
NGHTTP2_TYPEMASK_ALTSVC = 1 << 0,
|
|
|
|
NGHTTP2_TYPEMASK_ORIGIN = 1 << 1
|
2016-04-09 11:23:15 +02:00
|
|
|
} nghttp2_typemask;
|
|
|
|
|
2014-02-18 15:23:11 +01:00
|
|
|
typedef enum {
|
|
|
|
NGHTTP2_OB_POP_ITEM,
|
2015-04-03 16:10:51 +02:00
|
|
|
NGHTTP2_OB_SEND_DATA,
|
2015-04-05 15:35:40 +02:00
|
|
|
NGHTTP2_OB_SEND_NO_COPY,
|
|
|
|
NGHTTP2_OB_SEND_CLIENT_MAGIC
|
2014-02-18 15:23:11 +01:00
|
|
|
} nghttp2_outbound_state;
|
|
|
|
|
2012-01-24 14:02:24 +01:00
|
|
|
typedef struct {
|
2013-07-12 17:19:03 +02:00
|
|
|
nghttp2_outbound_item *item;
|
2014-03-13 14:11:02 +01:00
|
|
|
nghttp2_bufs framebufs;
|
2014-02-18 15:23:11 +01:00
|
|
|
nghttp2_outbound_state state;
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_active_outbound_item;
|
2012-01-24 14:02:24 +01:00
|
|
|
|
2014-03-22 09:16:25 +01:00
|
|
|
/* Buffer length for inbound raw byte stream used in
|
|
|
|
nghttp2_session_recv(). */
|
2013-07-12 17:19:03 +02:00
|
|
|
#define NGHTTP2_INBOUND_BUFFER_LENGTH 16384
|
2012-02-07 17:25:26 +01:00
|
|
|
|
2015-08-23 14:22:25 +02:00
|
|
|
/* The default maximum number of incoming reserved streams */
|
|
|
|
#define NGHTTP2_MAX_INCOMING_RESERVED_STREAMS 200
|
|
|
|
|
2015-12-23 08:38:30 +01:00
|
|
|
/* Even if we have less SETTINGS_MAX_CONCURRENT_STREAMS than this
|
|
|
|
number, we keep NGHTTP2_MIN_IDLE_STREAMS streams in idle state */
|
|
|
|
#define NGHTTP2_MIN_IDLE_STREAMS 16
|
|
|
|
|
2015-09-29 17:44:08 +02:00
|
|
|
/* The maximum number of items in outbound queue, which is considered
|
|
|
|
as flooding caused by peer. All frames are not considered here.
|
|
|
|
We only consider PING + ACK and SETTINGS + ACK. This is because
|
|
|
|
they both are response to the frame initiated by peer and peer can
|
|
|
|
send as many of them as they want. If peer does not read network,
|
|
|
|
response frames are stacked up, which leads to memory exhaustion.
|
|
|
|
The value selected here is arbitrary, but safe value and if we have
|
|
|
|
these frames in this number, it is considered suspicious. */
|
2015-10-25 08:23:29 +01:00
|
|
|
#define NGHTTP2_MAX_OBQ_FLOOD_ITEM 10000
|
2015-09-29 17:44:08 +02:00
|
|
|
|
More strict stream state handling
Previously, in server side, we used closed streams to detect the error
that the misbehaving client sends a frame on the incoming stream it
explicitly closed. With this commit, we make a further step, and
detect one more error case. Since we retain closed streams as long as
the sum of its size and the number of opened streams are equal or less
than max concurrent streams, we can safely say that if we get a frame
which is sent on the stream that is not found in either closed or
opened stream, it is already closed or has not existed. Then we can
send GOAWAY.
The previous code shrinks closed streams when we closed another
stream, but now it is removed. It is enough to adjust closed streams
when new incoming stream is created.
While creating this commit, we noticed that
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS is defined as INT32_MAX. But
since SETTINGS can contain value up to UINT32_MAX, it is not enough.
However, since the stream ID space is limited to INT32_MAX, it is high
enough. We could keep this value, but this time we deprecate
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS macro. While it is in public
header, the effect of deprecating it is negligible because of the
reason we wrote above, and usually application sets much smaller value
(say, 100) as SETTINGS_MAX_CONCURRENT_STREAMS.
2016-08-07 07:34:13 +02:00
|
|
|
/* The default value of maximum number of concurrent streams. */
|
|
|
|
#define NGHTTP2_DEFAULT_MAX_CONCURRENT_STREAMS 0xffffffffu
|
|
|
|
|
2012-05-25 03:46:40 +02:00
|
|
|
/* Internal state when receiving incoming frame */
|
2012-01-24 14:02:24 +01:00
|
|
|
typedef enum {
|
2012-05-25 03:46:40 +02:00
|
|
|
/* Receiving frame header */
|
2015-04-05 15:35:40 +02:00
|
|
|
NGHTTP2_IB_READ_CLIENT_MAGIC,
|
2014-10-09 14:37:18 +02:00
|
|
|
NGHTTP2_IB_READ_FIRST_SETTINGS,
|
2014-01-26 07:44:43 +01:00
|
|
|
NGHTTP2_IB_READ_HEAD,
|
|
|
|
NGHTTP2_IB_READ_NBYTE,
|
|
|
|
NGHTTP2_IB_READ_HEADER_BLOCK,
|
|
|
|
NGHTTP2_IB_IGN_HEADER_BLOCK,
|
|
|
|
NGHTTP2_IB_IGN_PAYLOAD,
|
|
|
|
NGHTTP2_IB_FRAME_SIZE_ERROR,
|
|
|
|
NGHTTP2_IB_READ_SETTINGS,
|
|
|
|
NGHTTP2_IB_READ_GOAWAY_DEBUG,
|
2014-01-26 12:31:28 +01:00
|
|
|
NGHTTP2_IB_EXPECT_CONTINUATION,
|
|
|
|
NGHTTP2_IB_IGN_CONTINUATION,
|
2014-02-12 13:35:40 +01:00
|
|
|
NGHTTP2_IB_READ_PAD_DATA,
|
2014-01-26 07:44:43 +01:00
|
|
|
NGHTTP2_IB_READ_DATA,
|
2015-02-14 17:20:10 +01:00
|
|
|
NGHTTP2_IB_IGN_DATA,
|
2015-10-10 15:27:48 +02:00
|
|
|
NGHTTP2_IB_IGN_ALL,
|
2016-04-03 15:58:25 +02:00
|
|
|
NGHTTP2_IB_READ_ALTSVC_PAYLOAD,
|
2018-05-10 03:57:02 +02:00
|
|
|
NGHTTP2_IB_READ_ORIGIN_PAYLOAD,
|
2015-10-10 15:27:48 +02:00
|
|
|
NGHTTP2_IB_READ_EXTENSION_PAYLOAD
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_inbound_state;
|
2012-01-24 14:02:24 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2013-09-28 10:59:24 +02:00
|
|
|
nghttp2_frame frame;
|
2014-06-09 16:16:54 +02:00
|
|
|
/* Storage for extension frame payload. frame->ext.payload points
|
|
|
|
to this structure to avoid frequent memory allocation. */
|
|
|
|
nghttp2_ext_frame_payload ext_frame_payload;
|
2016-04-10 09:36:04 +02:00
|
|
|
/* The received SETTINGS entry. For the standard settings entries,
|
|
|
|
we only keep the last seen value. For
|
|
|
|
SETTINGS_HEADER_TABLE_SIZE, we also keep minimum value in the
|
|
|
|
last index. */
|
|
|
|
nghttp2_settings_entry *iv;
|
2014-03-22 10:27:38 +01:00
|
|
|
/* buffer pointers to small buffer, raw_sbuf */
|
|
|
|
nghttp2_buf sbuf;
|
|
|
|
/* buffer pointers to large buffer, raw_lbuf */
|
|
|
|
nghttp2_buf lbuf;
|
|
|
|
/* Large buffer, malloced on demand */
|
|
|
|
uint8_t *raw_lbuf;
|
2014-01-26 07:44:43 +01:00
|
|
|
/* The number of entry filled in |iv| */
|
|
|
|
size_t niv;
|
2016-04-10 09:36:04 +02:00
|
|
|
/* The number of entries |iv| can store. */
|
|
|
|
size_t max_niv;
|
2014-01-26 07:44:43 +01:00
|
|
|
/* How many bytes we still need to receive for current frame */
|
|
|
|
size_t payloadleft;
|
2014-02-08 16:35:21 +01:00
|
|
|
/* padding length for the current frame */
|
|
|
|
size_t padlen;
|
2013-12-06 15:17:38 +01:00
|
|
|
nghttp2_inbound_state state;
|
2014-08-05 18:49:36 +02:00
|
|
|
/* Small buffer. Currently the largest contiguous chunk to buffer
|
|
|
|
is frame header. We buffer part of payload, but they are smaller
|
|
|
|
than frame header. */
|
|
|
|
uint8_t raw_sbuf[NGHTTP2_FRAME_HDLEN];
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_inbound_frame;
|
2012-01-24 14:02:24 +01:00
|
|
|
|
2014-06-10 14:29:19 +02:00
|
|
|
typedef struct {
|
|
|
|
uint32_t header_table_size;
|
|
|
|
uint32_t enable_push;
|
|
|
|
uint32_t max_concurrent_streams;
|
|
|
|
uint32_t initial_window_size;
|
2014-07-27 09:58:04 +02:00
|
|
|
uint32_t max_frame_size;
|
2014-10-28 15:40:47 +01:00
|
|
|
uint32_t max_header_list_size;
|
2018-03-10 09:19:45 +01:00
|
|
|
uint32_t enable_connect_protocol;
|
2014-06-10 14:29:19 +02:00
|
|
|
} nghttp2_settings_storage;
|
|
|
|
|
2012-01-28 11:22:38 +01:00
|
|
|
typedef enum {
|
2013-07-12 17:19:03 +02:00
|
|
|
NGHTTP2_GOAWAY_NONE = 0,
|
2014-11-28 14:59:13 +01:00
|
|
|
/* Flag means that connection should be terminated after sending GOAWAY. */
|
2014-11-29 08:28:08 +01:00
|
|
|
NGHTTP2_GOAWAY_TERM_ON_SEND = 0x1,
|
2014-11-28 14:59:13 +01:00
|
|
|
/* Flag means GOAWAY to terminate session has been sent */
|
|
|
|
NGHTTP2_GOAWAY_TERM_SENT = 0x2,
|
2015-01-07 14:53:43 +01:00
|
|
|
/* Flag means GOAWAY was sent */
|
|
|
|
NGHTTP2_GOAWAY_SENT = 0x4,
|
|
|
|
/* Flag means GOAWAY was received */
|
2015-04-30 00:28:18 +02:00
|
|
|
NGHTTP2_GOAWAY_RECV = 0x8
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_goaway_flag;
|
2012-01-28 11:22:38 +01:00
|
|
|
|
2015-07-22 17:36:00 +02:00
|
|
|
/* nghttp2_inflight_settings stores the SETTINGS entries which local
|
|
|
|
endpoint has sent to the remote endpoint, and has not received ACK
|
|
|
|
yet. */
|
|
|
|
struct nghttp2_inflight_settings {
|
|
|
|
struct nghttp2_inflight_settings *next;
|
|
|
|
nghttp2_settings_entry *iv;
|
|
|
|
size_t niv;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct nghttp2_inflight_settings nghttp2_inflight_settings;
|
|
|
|
|
2013-07-12 17:19:03 +02:00
|
|
|
struct nghttp2_session {
|
|
|
|
nghttp2_map /* <nghttp2_stream*> */ streams;
|
2015-08-13 16:32:13 +02:00
|
|
|
/* root of dependency tree*/
|
|
|
|
nghttp2_stream root;
|
2015-04-24 15:30:32 +02:00
|
|
|
/* Queue for outbound urgent frames (PING and SETTINGS) */
|
|
|
|
nghttp2_outbound_queue ob_urgent;
|
|
|
|
/* Queue for non-DATA frames */
|
|
|
|
nghttp2_outbound_queue ob_reg;
|
|
|
|
/* Queue for outbound stream-creating HEADERS (request or push
|
|
|
|
response) frame, which are subject to
|
|
|
|
SETTINGS_MAX_CONCURRENT_STREAMS limit. */
|
|
|
|
nghttp2_outbound_queue ob_syn;
|
2013-07-12 17:19:03 +02:00
|
|
|
nghttp2_active_outbound_item aob;
|
|
|
|
nghttp2_inbound_frame iframe;
|
2014-01-26 09:53:04 +01:00
|
|
|
nghttp2_hd_deflater hd_deflater;
|
|
|
|
nghttp2_hd_inflater hd_inflater;
|
2013-12-06 15:17:38 +01:00
|
|
|
nghttp2_session_callbacks callbacks;
|
2014-12-07 15:07:13 +01:00
|
|
|
/* Memory allocator */
|
|
|
|
nghttp2_mem mem;
|
2015-04-24 18:00:02 +02:00
|
|
|
/* Base value when we schedule next DATA frame write. This is
|
|
|
|
updated when one frame was written. */
|
2014-05-08 16:07:29 +02:00
|
|
|
uint64_t last_cycle;
|
2013-12-06 15:17:38 +01:00
|
|
|
void *user_data;
|
2015-12-03 14:48:41 +01:00
|
|
|
/* Points to the latest incoming closed stream. NULL if there is no
|
|
|
|
closed stream. Only used when session is initialized as
|
|
|
|
server. */
|
2014-03-30 10:41:54 +02:00
|
|
|
nghttp2_stream *closed_stream_head;
|
2015-12-03 14:48:41 +01:00
|
|
|
/* Points to the oldest incoming closed stream. NULL if there is no
|
|
|
|
closed stream. Only used when session is initialized as
|
|
|
|
server. */
|
2014-03-30 10:41:54 +02:00
|
|
|
nghttp2_stream *closed_stream_tail;
|
2014-12-12 16:03:19 +01:00
|
|
|
/* Points to the latest idle stream. NULL if there is no idle
|
|
|
|
stream. Only used when session is initialized as server .*/
|
|
|
|
nghttp2_stream *idle_stream_head;
|
|
|
|
/* Points to the oldest idle stream. NULL if there is no idle
|
|
|
|
stream. Only used when session is initialized as erver. */
|
|
|
|
nghttp2_stream *idle_stream_tail;
|
2015-07-22 17:36:00 +02:00
|
|
|
/* Queue of In-flight SETTINGS values. SETTINGS bearing ACK is not
|
|
|
|
considered as in-flight. */
|
|
|
|
nghttp2_inflight_settings *inflight_settings_head;
|
2013-12-06 15:17:38 +01:00
|
|
|
/* The number of outgoing streams. This will be capped by
|
2014-06-10 14:29:19 +02:00
|
|
|
remote_settings.max_concurrent_streams. */
|
2013-12-06 15:17:38 +01:00
|
|
|
size_t num_outgoing_streams;
|
|
|
|
/* The number of incoming streams. This will be capped by
|
2014-06-10 14:29:19 +02:00
|
|
|
local_settings.max_concurrent_streams. */
|
2013-12-06 15:17:38 +01:00
|
|
|
size_t num_incoming_streams;
|
2015-08-23 14:22:25 +02:00
|
|
|
/* The number of incoming reserved streams. This is the number of
|
|
|
|
streams in reserved (remote) state. RFC 7540 does not limit this
|
|
|
|
number. nghttp2 offers
|
|
|
|
nghttp2_option_set_max_reserved_remote_streams() to achieve this.
|
|
|
|
If it is used, num_incoming_streams is capped by
|
|
|
|
max_incoming_reserved_streams. Client application should
|
|
|
|
consider to set this because without that server can send
|
|
|
|
arbitrary number of PUSH_PROMISE, and exhaust client's memory. */
|
|
|
|
size_t num_incoming_reserved_streams;
|
|
|
|
/* The maximum number of incoming reserved streams (reserved
|
|
|
|
(remote) state). RST_STREAM will be sent for the pushed stream
|
|
|
|
which exceeds this limit. */
|
|
|
|
size_t max_incoming_reserved_streams;
|
2014-03-30 10:41:54 +02:00
|
|
|
/* The number of closed streams still kept in |streams| hash. The
|
|
|
|
closed streams can be accessed through single linked list
|
|
|
|
|closed_stream_head|. The current implementation only keeps
|
|
|
|
incoming streams and session is initialized as server. */
|
|
|
|
size_t num_closed_streams;
|
2014-12-12 16:03:19 +01:00
|
|
|
/* The number of idle streams kept in |streams| hash. The idle
|
|
|
|
streams can be accessed through doubly linked list
|
|
|
|
|idle_stream_head|. The current implementation only keeps idle
|
|
|
|
streams if session is initialized as server. */
|
|
|
|
size_t num_idle_streams;
|
2012-02-16 12:54:30 +01:00
|
|
|
/* The number of bytes allocated for nvbuf */
|
|
|
|
size_t nvbuflen;
|
2015-09-29 17:44:08 +02:00
|
|
|
/* Counter for detecting flooding in outbound queue */
|
|
|
|
size_t obq_flood_counter_;
|
2016-06-14 17:00:30 +02:00
|
|
|
/* The maximum length of header block to send. Calculated by the
|
|
|
|
same way as nghttp2_hd_deflate_bound() does. */
|
|
|
|
size_t max_send_header_block_length;
|
2013-12-06 15:17:38 +01:00
|
|
|
/* Next Stream ID. Made unsigned int to detect >= (1 << 31). */
|
|
|
|
uint32_t next_stream_id;
|
2016-01-10 16:31:52 +01:00
|
|
|
/* The last stream ID this session initiated. For client session,
|
|
|
|
this is the last stream ID it has sent. For server session, it
|
|
|
|
is the last promised stream ID sent in PUSH_PROMISE. */
|
2016-01-23 06:47:39 +01:00
|
|
|
int32_t last_sent_stream_id;
|
2013-12-06 15:17:38 +01:00
|
|
|
/* The largest stream ID received so far */
|
|
|
|
int32_t last_recv_stream_id;
|
|
|
|
/* The largest stream ID which has been processed in some way. This
|
|
|
|
value will be used as last-stream-id when sending GOAWAY
|
|
|
|
frame. */
|
|
|
|
int32_t last_proc_stream_id;
|
|
|
|
/* Counter of unique ID of PING. Wraps when it exceeds
|
|
|
|
NGHTTP2_MAX_UNIQUE_ID */
|
|
|
|
uint32_t next_unique_id;
|
2014-06-18 04:03:55 +02:00
|
|
|
/* This is the last-stream-ID we have sent in GOAWAY */
|
|
|
|
int32_t local_last_stream_id;
|
2013-11-28 15:26:34 +01:00
|
|
|
/* This is the value in GOAWAY frame received from remote endpoint. */
|
2014-06-18 03:56:32 +02:00
|
|
|
int32_t remote_last_stream_id;
|
2013-07-15 14:45:59 +02:00
|
|
|
/* Current sender window size. This value is computed against the
|
|
|
|
current initial window size of remote endpoint. */
|
2013-08-08 18:31:15 +02:00
|
|
|
int32_t remote_window_size;
|
2013-07-15 14:45:59 +02:00
|
|
|
/* Keep track of the number of bytes received without
|
2013-10-30 15:43:40 +01:00
|
|
|
WINDOW_UPDATE. This could be negative after submitting negative
|
|
|
|
value to WINDOW_UPDATE. */
|
2013-07-15 14:45:59 +02:00
|
|
|
int32_t recv_window_size;
|
2014-07-25 14:26:03 +02:00
|
|
|
/* The number of bytes consumed by the application and now is
|
|
|
|
subject to WINDOW_UPDATE. This is only used when auto
|
|
|
|
WINDOW_UPDATE is turned off. */
|
|
|
|
int32_t consumed_size;
|
2013-10-12 10:02:37 +02:00
|
|
|
/* The amount of recv_window_size cut using submitting negative
|
|
|
|
value to WINDOW_UPDATE */
|
|
|
|
int32_t recv_reduction;
|
2013-08-08 17:58:52 +02:00
|
|
|
/* window size for local flow control. It is initially set to
|
|
|
|
NGHTTP2_INITIAL_CONNECTION_WINDOW_SIZE and could be
|
|
|
|
increased/decreased by submitting WINDOW_UPDATE. See
|
|
|
|
nghttp2_submit_window_update(). */
|
|
|
|
int32_t local_window_size;
|
2018-05-31 05:24:00 +02:00
|
|
|
/* This flag is used to indicate that the local endpoint received initial
|
|
|
|
SETTINGS frame from the remote endpoint. */
|
|
|
|
uint8_t remote_settings_received;
|
|
|
|
/* Settings value received from the remote endpoint. */
|
2014-06-10 14:29:19 +02:00
|
|
|
nghttp2_settings_storage remote_settings;
|
2012-03-09 16:10:11 +01:00
|
|
|
/* Settings value of the local endpoint. */
|
2014-06-10 14:29:19 +02:00
|
|
|
nghttp2_settings_storage local_settings;
|
2013-07-12 17:19:03 +02:00
|
|
|
/* Option flags. This is bitwise-OR of 0 or more of nghttp2_optmask. */
|
2012-05-08 15:59:34 +02:00
|
|
|
uint32_t opt_flags;
|
2014-02-20 14:59:29 +01:00
|
|
|
/* Unacked local SETTINGS_MAX_CONCURRENT_STREAMS value. We use this
|
|
|
|
to refuse the incoming stream if it exceeds this value. */
|
|
|
|
uint32_t pending_local_max_concurrent_stream;
|
2017-07-27 17:51:34 +02:00
|
|
|
/* The bitwise OR of zero or more of nghttp2_typemask to indicate
|
2016-04-09 11:23:15 +02:00
|
|
|
that the default handling of extension frame is enabled. */
|
|
|
|
uint32_t builtin_recv_ext_types;
|
2015-03-07 08:17:40 +01:00
|
|
|
/* Unacked local ENABLE_PUSH value. We use this to refuse
|
|
|
|
PUSH_PROMISE before SETTINGS ACK is received. */
|
|
|
|
uint8_t pending_enable_push;
|
2018-09-27 17:11:33 +02:00
|
|
|
/* Unacked local ENABLE_CONNECT_PROTOCOL value. We use this to
|
|
|
|
accept :protocol header field before SETTINGS_ACK is received. */
|
|
|
|
uint8_t pending_enable_connect_protocol;
|
2013-12-06 15:17:38 +01:00
|
|
|
/* Nonzero if the session is server side. */
|
|
|
|
uint8_t server;
|
2017-10-28 15:25:42 +02:00
|
|
|
/* Flags indicating GOAWAY is sent and/or received. The flags are
|
2013-12-06 15:17:38 +01:00
|
|
|
composed by bitwise OR-ing nghttp2_goaway_flag. */
|
|
|
|
uint8_t goaway_flags;
|
2015-09-30 18:19:57 +02:00
|
|
|
/* This flag is used to reduce excessive queuing of WINDOW_UPDATE to
|
|
|
|
this session. The nonzero does not necessarily mean
|
|
|
|
WINDOW_UPDATE is not queued. */
|
|
|
|
uint8_t window_update_queued;
|
2015-10-14 17:17:07 +02:00
|
|
|
/* Bitfield of extension frame types that application is willing to
|
2016-02-24 15:59:01 +01:00
|
|
|
receive. To designate the bit of given frame type i, use
|
|
|
|
user_recv_ext_types[i / 8] & (1 << (i & 0x7)). First 10 frame
|
|
|
|
types are standard frame types and not used in this bitfield. If
|
|
|
|
bit is set, it indicates that incoming frame with that type is
|
|
|
|
passed to user defined callbacks, otherwise they are ignored. */
|
2015-10-14 17:17:07 +02:00
|
|
|
uint8_t user_recv_ext_types[32];
|
2012-01-31 13:32:46 +01:00
|
|
|
};
|
2012-01-24 14:02:24 +01:00
|
|
|
|
2012-05-11 15:58:12 +02:00
|
|
|
/* Struct used when updating initial window size of each active
|
|
|
|
stream. */
|
|
|
|
typedef struct {
|
2013-07-12 17:19:03 +02:00
|
|
|
nghttp2_session *session;
|
2012-05-11 15:58:12 +02:00
|
|
|
int32_t new_window_size, old_window_size;
|
2013-07-12 17:19:03 +02:00
|
|
|
} nghttp2_update_window_size_arg;
|
2012-05-11 15:58:12 +02:00
|
|
|
|
2014-11-28 14:59:13 +01:00
|
|
|
typedef struct {
|
|
|
|
nghttp2_session *session;
|
|
|
|
/* linked list of streams to close */
|
|
|
|
nghttp2_stream *head;
|
|
|
|
int32_t last_stream_id;
|
|
|
|
/* nonzero if GOAWAY is sent to peer, which means we are going to
|
|
|
|
close incoming streams. zero if GOAWAY is received from peer and
|
|
|
|
we are going to close outgoing streams. */
|
|
|
|
int incoming;
|
|
|
|
} nghttp2_close_stream_on_goaway_arg;
|
|
|
|
|
2012-01-24 14:02:24 +01:00
|
|
|
/* TODO stream timeout etc */
|
|
|
|
|
2012-02-02 15:19:01 +01:00
|
|
|
/*
|
2012-02-22 15:39:30 +01:00
|
|
|
* Returns nonzero value if |stream_id| is initiated by local
|
|
|
|
* endpoint.
|
2012-02-02 15:19:01 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_is_my_stream_id(nghttp2_session *session,
|
2012-02-02 15:19:01 +01:00
|
|
|
int32_t stream_id);
|
|
|
|
|
2014-10-02 17:59:44 +02:00
|
|
|
/*
|
|
|
|
* Adds |item| to the outbound queue in |session|. When this function
|
|
|
|
* succeeds, it takes ownership of |item|. So caller must not free it
|
|
|
|
* on success.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2014-10-02 17:59:44 +02:00
|
|
|
* NGHTTP2_ERR_STREAM_CLOSED
|
2015-12-02 13:16:30 +01:00
|
|
|
* Stream already closed (DATA and PUSH_PROMISE frame only)
|
2012-01-29 11:07:31 +01:00
|
|
|
*/
|
2014-10-02 17:59:44 +02:00
|
|
|
int nghttp2_session_add_item(nghttp2_session *session,
|
|
|
|
nghttp2_outbound_item *item);
|
2012-01-24 14:02:24 +01:00
|
|
|
|
2012-02-22 15:39:30 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Adds RST_STREAM frame for the stream |stream_id| with the error
|
|
|
|
* code |error_code|. This is a convenient function built on top of
|
2013-07-12 17:19:03 +02:00
|
|
|
* nghttp2_session_add_frame() to add RST_STREAM easily.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2014-03-21 16:51:40 +01:00
|
|
|
* This function simply returns 0 without adding RST_STREAM frame if
|
|
|
|
* given stream is in NGHTTP2_STREAM_CLOSING state, because multiple
|
|
|
|
* RST_STREAM for a stream is redundant.
|
|
|
|
*
|
2012-02-22 15:39:30 +01:00
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_session_add_rst_stream(nghttp2_session *session, int32_t stream_id,
|
2014-08-23 10:34:56 +02:00
|
|
|
uint32_t error_code);
|
2012-01-25 13:31:28 +01:00
|
|
|
|
2012-02-22 15:39:30 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Adds PING frame. This is a convenient functin built on top of
|
|
|
|
* nghttp2_session_add_frame() to add PING easily.
|
|
|
|
*
|
|
|
|
* If the |opaque_data| is not NULL, it must point to 8 bytes memory
|
|
|
|
* region of data. The data pointed by |opaque_data| is copied. It can
|
|
|
|
* be NULL. In this case, 8 bytes NULL is used.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2015-09-30 15:16:03 +02:00
|
|
|
* NGHTTP2_ERR_FLOODED
|
2015-09-29 17:44:08 +02:00
|
|
|
* There are too many items in outbound queue; this only happens
|
|
|
|
* if NGHTTP2_FLAG_ACK is set in |flags|
|
2012-02-22 15:39:30 +01:00
|
|
|
*/
|
2013-07-15 14:45:59 +02:00
|
|
|
int nghttp2_session_add_ping(nghttp2_session *session, uint8_t flags,
|
2014-07-01 17:59:36 +02:00
|
|
|
const uint8_t *opaque_data);
|
2012-01-27 15:05:29 +01:00
|
|
|
|
2012-02-22 15:39:30 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Adds GOAWAY frame with the last-stream-ID |last_stream_id| and the
|
|
|
|
* error code |error_code|. This is a convenient function built on top
|
2015-01-21 17:43:56 +01:00
|
|
|
* of nghttp2_session_add_frame() to add GOAWAY easily. The
|
|
|
|
* |aux_flags| are bitwise-OR of one or more of
|
|
|
|
* nghttp2_goaway_aux_flag.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2014-04-01 14:55:29 +02:00
|
|
|
* NGHTTP2_ERR_INVALID_ARGUMENT
|
|
|
|
* The |opaque_data_len| is too large.
|
2012-02-22 15:39:30 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_session_add_goaway(nghttp2_session *session, int32_t last_stream_id,
|
|
|
|
uint32_t error_code, const uint8_t *opaque_data,
|
2015-01-21 17:43:56 +01:00
|
|
|
size_t opaque_data_len, uint8_t aux_flags);
|
2012-01-28 11:22:38 +01:00
|
|
|
|
2012-02-25 16:12:32 +01:00
|
|
|
/*
|
|
|
|
* Adds WINDOW_UPDATE frame with stream ID |stream_id| and
|
2013-07-15 14:45:59 +02:00
|
|
|
* window-size-increment |window_size_increment|. This is a convenient
|
2013-07-12 17:19:03 +02:00
|
|
|
* function built on top of nghttp2_session_add_frame() to add
|
2012-02-25 16:12:32 +01:00
|
|
|
* WINDOW_UPDATE easily.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-25 16:12:32 +01:00
|
|
|
* Out of memory.
|
|
|
|
*/
|
2013-07-15 14:45:59 +02:00
|
|
|
int nghttp2_session_add_window_update(nghttp2_session *session, uint8_t flags,
|
2012-02-25 16:12:32 +01:00
|
|
|
int32_t stream_id,
|
2013-07-15 14:45:59 +02:00
|
|
|
int32_t window_size_increment);
|
2012-02-25 16:12:32 +01:00
|
|
|
|
2013-10-27 11:22:51 +01:00
|
|
|
/*
|
|
|
|
* Adds SETTINGS frame.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory.
|
2015-09-30 15:16:03 +02:00
|
|
|
* NGHTTP2_ERR_FLOODED
|
2015-09-29 17:44:08 +02:00
|
|
|
* There are too many items in outbound queue; this only happens
|
|
|
|
* if NGHTTP2_FLAG_ACK is set in |flags|
|
2013-10-27 11:22:51 +01:00
|
|
|
*/
|
|
|
|
int nghttp2_session_add_settings(nghttp2_session *session, uint8_t flags,
|
|
|
|
const nghttp2_settings_entry *iv, size_t niv);
|
|
|
|
|
2012-01-25 15:46:07 +01:00
|
|
|
/*
|
|
|
|
* Creates new stream in |session| with stream ID |stream_id|,
|
2014-03-25 18:04:24 +01:00
|
|
|
* priority |pri_spec| and flags |flags|. The |flags| is bitwise OR
|
|
|
|
* of nghttp2_stream_flag. Since this function is called when initial
|
2013-07-15 14:45:59 +02:00
|
|
|
* HEADERS is sent or received, these flags are taken from it. The
|
|
|
|
* state of stream is set to |initial_state|. The |stream_user_data|
|
|
|
|
* is a pointer to the arbitrary user supplied data to be associated
|
|
|
|
* to this stream.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2015-02-09 13:45:55 +01:00
|
|
|
* If |initial_state| is NGHTTP2_STREAM_RESERVED, this function sets
|
|
|
|
* NGHTTP2_STREAM_FLAG_PUSH flag set.
|
|
|
|
*
|
2012-02-22 15:39:30 +01:00
|
|
|
* This function returns a pointer to created new stream object, or
|
|
|
|
* NULL.
|
2015-12-23 08:38:30 +01:00
|
|
|
*
|
|
|
|
* This function adjusts neither the number of closed streams or idle
|
|
|
|
* streams. The caller should manually call
|
|
|
|
* nghttp2_session_adjust_closed_stream() or
|
|
|
|
* nghttp2_session_adjust_idle_stream() respectively.
|
2012-01-25 15:46:07 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_stream *nghttp2_session_open_stream(nghttp2_session *session,
|
|
|
|
int32_t stream_id, uint8_t flags,
|
2014-03-25 18:04:24 +01:00
|
|
|
nghttp2_priority_spec *pri_spec,
|
2013-07-12 17:19:03 +02:00
|
|
|
nghttp2_stream_state initial_state,
|
2012-02-03 17:37:21 +01:00
|
|
|
void *stream_user_data);
|
2012-01-24 14:02:24 +01:00
|
|
|
|
2012-01-25 17:04:01 +01:00
|
|
|
/*
|
2012-01-29 15:00:33 +01:00
|
|
|
* Closes stream whose stream ID is |stream_id|. The reason of closure
|
2013-07-15 14:45:59 +02:00
|
|
|
* is indicated by the |error_code|. When closing the stream,
|
2012-02-22 15:39:30 +01:00
|
|
|
* on_stream_close_callback will be called.
|
|
|
|
*
|
2014-03-30 10:41:54 +02:00
|
|
|
* If the session is initialized as server and |stream| is incoming
|
|
|
|
* stream, stream is just marked closed and this function calls
|
|
|
|
* nghttp2_session_keep_closed_stream() with |stream|. Otherwise,
|
|
|
|
* |stream| will be deleted from memory.
|
|
|
|
*
|
2012-02-22 15:39:30 +01:00
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2014-03-25 18:04:24 +01:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_INVALID_ARGUMENT
|
2012-02-22 15:39:30 +01:00
|
|
|
* The specified stream does not exist.
|
2014-03-25 18:04:24 +01:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The callback function failed.
|
2012-01-25 17:04:01 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id,
|
2014-08-23 10:34:56 +02:00
|
|
|
uint32_t error_code);
|
2012-02-02 15:19:01 +01:00
|
|
|
|
2014-03-30 10:41:54 +02:00
|
|
|
/*
|
|
|
|
* Deletes |stream| from memory. After this function returns, stream
|
|
|
|
* cannot be accessed.
|
|
|
|
*
|
2015-08-16 12:01:10 +02:00
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
2014-03-30 10:41:54 +02:00
|
|
|
*/
|
2015-08-16 12:01:10 +02:00
|
|
|
int nghttp2_session_destroy_stream(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream);
|
2014-03-30 10:41:54 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Tries to keep incoming closed stream |stream|. Due to the
|
|
|
|
* limitation of maximum number of streams in memory, |stream| is not
|
|
|
|
* closed and just deleted from memory (see
|
|
|
|
* nghttp2_session_destroy_stream).
|
|
|
|
*/
|
2015-12-23 08:38:30 +01:00
|
|
|
void nghttp2_session_keep_closed_stream(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream);
|
2014-03-30 10:41:54 +02:00
|
|
|
|
2014-11-07 16:36:47 +01:00
|
|
|
/*
|
2014-12-12 16:03:19 +01:00
|
|
|
* Appends |stream| to linked list |session->idle_stream_head|. We
|
|
|
|
* apply fixed limit for list size. To fit into that limit, one or
|
|
|
|
* more oldest streams are removed from list as necessary.
|
2014-11-07 16:36:47 +01:00
|
|
|
*/
|
2015-12-23 08:38:30 +01:00
|
|
|
void nghttp2_session_keep_idle_stream(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream);
|
2014-11-07 16:36:47 +01:00
|
|
|
|
2014-11-12 16:17:28 +01:00
|
|
|
/*
|
2014-12-12 16:03:19 +01:00
|
|
|
* Detaches |stream| from idle streams linked list.
|
2014-11-12 16:17:28 +01:00
|
|
|
*/
|
2014-12-12 16:03:19 +01:00
|
|
|
void nghttp2_session_detach_idle_stream(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream);
|
2014-11-12 16:17:28 +01:00
|
|
|
|
2014-03-30 10:41:54 +02:00
|
|
|
/*
|
|
|
|
* Deletes closed stream to ensure that number of incoming streams
|
|
|
|
* including active and closed is in the maximum number of allowed
|
2015-12-23 08:38:30 +01:00
|
|
|
* stream.
|
2015-08-16 12:01:10 +02:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
2014-03-30 10:41:54 +02:00
|
|
|
*/
|
2015-12-23 08:38:30 +01:00
|
|
|
int nghttp2_session_adjust_closed_stream(nghttp2_session *session);
|
2014-03-30 10:41:54 +02:00
|
|
|
|
2014-12-12 16:03:19 +01:00
|
|
|
/*
|
|
|
|
* Deletes idle stream to ensure that number of idle streams is in
|
|
|
|
* certain limit.
|
2015-08-16 12:01:10 +02:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
2014-12-12 16:03:19 +01:00
|
|
|
*/
|
2015-08-16 12:01:10 +02:00
|
|
|
int nghttp2_session_adjust_idle_stream(nghttp2_session *session);
|
2014-12-12 16:03:19 +01:00
|
|
|
|
2012-01-28 16:08:51 +01:00
|
|
|
/*
|
2012-02-22 15:39:30 +01:00
|
|
|
* If further receptions and transmissions over the stream |stream_id|
|
2013-07-15 14:45:59 +02:00
|
|
|
* are disallowed, close the stream with error code NGHTTP2_NO_ERROR.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it
|
|
|
|
* succeeds, or one of the following negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_INVALID_ARGUMENT
|
2012-02-22 15:39:30 +01:00
|
|
|
* The specified stream does not exist.
|
2012-01-28 16:08:51 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_close_stream_if_shut_rdwr(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream);
|
2012-01-28 16:08:51 +01:00
|
|
|
|
2013-07-25 14:07:38 +02:00
|
|
|
int nghttp2_session_on_request_headers_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-01-25 15:46:07 +01:00
|
|
|
|
2013-07-25 14:07:38 +02:00
|
|
|
int nghttp2_session_on_response_headers_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame,
|
|
|
|
nghttp2_stream *stream);
|
2013-07-15 14:45:59 +02:00
|
|
|
|
2013-07-25 14:07:38 +02:00
|
|
|
int nghttp2_session_on_push_response_headers_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame,
|
|
|
|
nghttp2_stream *stream);
|
2013-07-24 18:49:05 +02:00
|
|
|
|
2012-01-25 15:46:07 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Called when HEADERS is received, assuming |frame| is properly
|
|
|
|
* initialized. This function does first validate received frame and
|
|
|
|
* then open stream and call callback functions.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_IGN_HEADER_BLOCK
|
|
|
|
* Frame was rejected and header block must be decoded but
|
|
|
|
* result must be ignored.
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The read_callback failed
|
2012-01-25 15:46:07 +01:00
|
|
|
*/
|
2013-07-15 14:45:59 +02:00
|
|
|
int nghttp2_session_on_headers_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame,
|
|
|
|
nghttp2_stream *stream);
|
2012-01-25 15:46:07 +01:00
|
|
|
|
2013-07-22 17:11:39 +02:00
|
|
|
/*
|
|
|
|
* Called when PRIORITY is received, assuming |frame| is properly
|
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory.
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The read_callback failed
|
2013-07-22 17:11:39 +02:00
|
|
|
*/
|
|
|
|
int nghttp2_session_on_priority_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
|
|
|
|
2012-01-27 15:22:27 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Called when RST_STREAM is received, assuming |frame| is properly
|
|
|
|
* initialized.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2013-10-27 11:22:51 +01:00
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The read_callback failed
|
2012-01-27 15:22:27 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_rst_stream_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-01-27 15:22:27 +01:00
|
|
|
|
2012-01-31 17:12:26 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Called when SETTINGS is received, assuming |frame| is properly
|
2013-10-27 11:22:51 +01:00
|
|
|
* initialized. If |noack| is non-zero, SETTINGS with ACK will not be
|
|
|
|
* submitted. If |frame| has NGHTTP2_FLAG_ACK flag set, no SETTINGS
|
|
|
|
* with ACK will not be submitted regardless of |noack|.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2013-10-27 11:22:51 +01:00
|
|
|
* This function returns 0 if it succeeds, or one the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The read_callback failed
|
2015-09-30 15:16:03 +02:00
|
|
|
* NGHTTP2_ERR_FLOODED
|
|
|
|
* There are too many items in outbound queue, and this is most
|
|
|
|
* likely caused by misbehaviour of peer.
|
2012-01-31 17:12:26 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_settings_received(nghttp2_session *session,
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_frame *frame, int noack);
|
2013-07-24 18:49:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Called when PUSH_PROMISE is received, assuming |frame| is properly
|
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory.
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_IGN_HEADER_BLOCK
|
|
|
|
* Frame was rejected and header block must be decoded but
|
|
|
|
* result must be ignored.
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The read_callback failed
|
2013-07-24 18:49:05 +02:00
|
|
|
*/
|
|
|
|
int nghttp2_session_on_push_promise_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-01-31 17:12:26 +01:00
|
|
|
|
2012-01-27 15:37:47 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Called when PING is received, assuming |frame| is properly
|
2012-02-22 15:39:30 +01:00
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2018-05-12 06:07:04 +02:00
|
|
|
* The callback function failed.
|
2015-09-30 15:16:03 +02:00
|
|
|
* NGHTTP2_ERR_FLOODED
|
|
|
|
* There are too many items in outbound queue, and this is most
|
|
|
|
* likely caused by misbehaviour of peer.
|
2012-01-27 15:37:47 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_ping_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-01-27 15:37:47 +01:00
|
|
|
|
2012-01-28 11:22:38 +01:00
|
|
|
/*
|
2013-07-15 14:45:59 +02:00
|
|
|
* Called when GOAWAY is received, assuming |frame| is properly
|
2012-02-22 15:39:30 +01:00
|
|
|
* initialized.
|
|
|
|
*
|
2014-04-01 14:47:51 +02:00
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory.
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2018-05-12 06:07:04 +02:00
|
|
|
* The callback function failed.
|
2012-01-28 11:22:38 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_goaway_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-01-28 11:22:38 +01:00
|
|
|
|
2012-01-27 11:10:13 +01:00
|
|
|
/*
|
2017-10-28 15:25:42 +02:00
|
|
|
* Called when WINDOW_UPDATE is received, assuming |frame| is properly
|
2013-07-15 14:45:59 +02:00
|
|
|
* initialized.
|
2012-02-25 16:12:32 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-25 16:12:32 +01:00
|
|
|
* Out of memory.
|
2014-04-01 14:47:51 +02:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2018-05-12 06:07:04 +02:00
|
|
|
* The callback function failed.
|
2012-02-25 16:12:32 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_window_update_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
2012-02-25 16:12:32 +01:00
|
|
|
|
2016-04-03 15:58:25 +02:00
|
|
|
/*
|
2017-10-28 15:25:42 +02:00
|
|
|
* Called when ALTSVC is received, assuming |frame| is properly
|
2016-04-03 15:58:25 +02:00
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2018-05-12 06:07:04 +02:00
|
|
|
* The callback function failed.
|
2016-04-03 15:58:25 +02:00
|
|
|
*/
|
|
|
|
int nghttp2_session_on_altsvc_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
|
|
|
|
2018-05-10 03:57:02 +02:00
|
|
|
/*
|
|
|
|
* Called when ORIGIN is received, assuming |frame| is properly
|
|
|
|
* initialized.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
|
|
|
* The callback function failed.
|
|
|
|
*/
|
|
|
|
int nghttp2_session_on_origin_received(nghttp2_session *session,
|
|
|
|
nghttp2_frame *frame);
|
|
|
|
|
2012-01-29 08:27:00 +01:00
|
|
|
/*
|
2014-01-27 14:13:41 +01:00
|
|
|
* Called when DATA is received, assuming |frame| is properly
|
|
|
|
* initialized.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-02-22 15:39:30 +01:00
|
|
|
* Out of memory.
|
2014-01-27 14:13:41 +01:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2018-05-12 06:07:04 +02:00
|
|
|
* The callback function failed.
|
2012-01-29 08:27:00 +01:00
|
|
|
*/
|
2013-07-12 17:19:03 +02:00
|
|
|
int nghttp2_session_on_data_received(nghttp2_session *session,
|
2014-01-27 14:13:41 +01:00
|
|
|
nghttp2_frame *frame);
|
2012-01-29 08:27:00 +01:00
|
|
|
|
2012-01-25 17:04:01 +01:00
|
|
|
/*
|
2013-07-12 17:19:03 +02:00
|
|
|
* Returns nghttp2_stream* object whose stream ID is |stream_id|. It
|
2014-03-30 10:41:54 +02:00
|
|
|
* could be NULL if such stream does not exist. This function returns
|
|
|
|
* NULL if stream is marked as closed.
|
2012-01-25 17:04:01 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_stream *nghttp2_session_get_stream(nghttp2_session *session,
|
2012-01-25 17:04:01 +01:00
|
|
|
int32_t stream_id);
|
|
|
|
|
2014-03-30 10:41:54 +02:00
|
|
|
/*
|
|
|
|
* This function behaves like nghttp2_session_get_stream(), but it
|
2014-11-07 16:36:47 +01:00
|
|
|
* returns stream object even if it is marked as closed or in
|
|
|
|
* NGHTTP2_STREAM_IDLE state.
|
2014-03-30 10:41:54 +02:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_stream *nghttp2_session_get_stream_raw(nghttp2_session *session,
|
2014-03-30 10:41:54 +02:00
|
|
|
int32_t stream_id);
|
|
|
|
|
2012-01-26 17:17:40 +01:00
|
|
|
/*
|
2012-02-22 15:39:30 +01:00
|
|
|
* Packs DATA frame |frame| in wire frame format and stores it in
|
2014-10-02 17:59:44 +02:00
|
|
|
* |bufs|. Payload will be read using |aux_data->data_prd|. The
|
|
|
|
* length of payload is at most |datamax| bytes.
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2014-04-01 14:59:26 +02:00
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
2012-02-22 15:39:30 +01:00
|
|
|
*
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_DEFERRED
|
2012-02-22 15:39:30 +01:00
|
|
|
* The DATA frame is postponed.
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE
|
2012-05-12 11:19:05 +02:00
|
|
|
* The read_callback failed (stream error).
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_NOMEM
|
2012-05-12 11:19:05 +02:00
|
|
|
* Out of memory.
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_ERR_CALLBACK_FAILURE
|
2012-05-12 11:19:05 +02:00
|
|
|
* The read_callback failed (session error).
|
2012-01-26 17:17:40 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
|
|
|
|
size_t datamax, nghttp2_frame *frame,
|
2015-04-16 14:38:13 +02:00
|
|
|
nghttp2_data_aux_data *aux_data,
|
|
|
|
nghttp2_stream *stream);
|
2012-01-26 17:17:40 +01:00
|
|
|
|
2012-02-05 16:14:19 +01:00
|
|
|
/*
|
2015-08-16 12:01:10 +02:00
|
|
|
* Pops and returns next item to send. If there is no such item,
|
2012-02-05 16:14:19 +01:00
|
|
|
* returns NULL. This function takes into account max concurrent
|
2015-08-16 12:01:10 +02:00
|
|
|
* streams. That means if session->ob_syn has item and max concurrent
|
|
|
|
* streams is reached, the even if other queues contain items, then
|
|
|
|
* this function returns NULL.
|
2012-02-05 16:14:19 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_outbound_item *
|
|
|
|
nghttp2_session_pop_next_ob_item(nghttp2_session *session);
|
2012-02-05 16:14:19 +01:00
|
|
|
|
|
|
|
/*
|
2015-08-16 12:01:10 +02:00
|
|
|
* Returns next item to send. If there is no such item, this function
|
2012-02-05 16:14:19 +01:00
|
|
|
* returns NULL. This function takes into account max concurrent
|
2015-08-16 12:01:10 +02:00
|
|
|
* streams. That means if session->ob_syn has item and max concurrent
|
|
|
|
* streams is reached, the even if other queues contain items, then
|
|
|
|
* this function returns NULL.
|
2012-02-05 16:14:19 +01:00
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
nghttp2_outbound_item *
|
|
|
|
nghttp2_session_get_next_ob_item(nghttp2_session *session);
|
2012-02-05 16:14:19 +01:00
|
|
|
|
2012-03-10 10:41:01 +01:00
|
|
|
/*
|
|
|
|
* Updates local settings with the |iv|. The number of elements in the
|
|
|
|
* array pointed by the |iv| is given by the |niv|. This function
|
|
|
|
* assumes that the all settings_id member in |iv| are in range 1 to
|
2013-07-12 17:19:03 +02:00
|
|
|
* NGHTTP2_SETTINGS_MAX, inclusive.
|
2013-08-08 17:58:52 +02:00
|
|
|
*
|
|
|
|
* While updating individual stream's local window size, if the window
|
|
|
|
* size becomes strictly larger than NGHTTP2_MAX_WINDOW_SIZE,
|
|
|
|
* RST_STREAM is issued against such a stream.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
2012-03-10 10:41:01 +01:00
|
|
|
*/
|
2013-08-08 17:58:52 +02:00
|
|
|
int nghttp2_session_update_local_settings(nghttp2_session *session,
|
|
|
|
nghttp2_settings_entry *iv,
|
|
|
|
size_t niv);
|
2012-03-10 10:41:01 +01:00
|
|
|
|
2013-08-09 16:40:41 +02:00
|
|
|
/*
|
2014-03-25 18:04:24 +01:00
|
|
|
* Re-prioritize |stream|. The new priority specification is
|
2015-06-21 09:31:30 +02:00
|
|
|
* |pri_spec|. Caller must ensure that stream->hd.stream_id !=
|
|
|
|
* pri_spec->stream_id.
|
2014-03-25 18:04:24 +01:00
|
|
|
*
|
2015-12-23 08:38:30 +01:00
|
|
|
* This function does not adjust the number of idle streams. The
|
|
|
|
* caller should call nghttp2_session_adjust_idle_stream() later.
|
|
|
|
*
|
2014-03-25 18:04:24 +01:00
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory
|
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_session_reprioritize_stream(nghttp2_session *session,
|
|
|
|
nghttp2_stream *stream,
|
|
|
|
const nghttp2_priority_spec *pri_spec);
|
2014-03-25 18:04:24 +01:00
|
|
|
|
2014-07-12 15:57:17 +02:00
|
|
|
/*
|
|
|
|
* Terminates current |session| with the |error_code|. The |reason|
|
|
|
|
* is NULL-terminated debug string.
|
|
|
|
*
|
|
|
|
* This function returns 0 if it succeeds, or one of the following
|
|
|
|
* negative error codes:
|
|
|
|
*
|
|
|
|
* NGHTTP2_ERR_NOMEM
|
|
|
|
* Out of memory.
|
|
|
|
* NGHTTP2_ERR_INVALID_ARGUMENT
|
|
|
|
* The |reason| is too long.
|
|
|
|
*/
|
2014-11-27 15:39:04 +01:00
|
|
|
int nghttp2_session_terminate_session_with_reason(nghttp2_session *session,
|
|
|
|
uint32_t error_code,
|
|
|
|
const char *reason);
|
2014-07-12 15:57:17 +02:00
|
|
|
|
2013-07-12 17:19:03 +02:00
|
|
|
#endif /* NGHTTP2_SESSION_H */
|