2020-03-13 13:36:33 -03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) Roman Arutyunyan
|
|
|
|
* Copyright (C) Nginx, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _NGX_HTTP_V3_H_INCLUDED_
|
|
|
|
#define _NGX_HTTP_V3_H_INCLUDED_
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_http.h>
|
2021-05-05 08:09:23 -04:00
|
|
|
|
2020-03-18 07:46:35 -03:00
|
|
|
#include <ngx_http_v3_parse.h>
|
2021-05-05 08:09:23 -04:00
|
|
|
#include <ngx_http_v3_encode.h>
|
2021-12-07 07:01:28 -03:00
|
|
|
#include <ngx_http_v3_uni.h>
|
|
|
|
#include <ngx_http_v3_table.h>
|
2020-03-13 13:36:33 -03:00
|
|
|
|
|
|
|
|
2021-12-02 07:59:09 -03:00
|
|
|
#define NGX_HTTP_V3_ALPN_PROTO "\x02h3"
|
2021-12-04 04:52:55 -03:00
|
|
|
#define NGX_HTTP_V3_HQ_ALPN_PROTO "\x0Ahq-interop"
|
2023-02-27 07:00:56 -03:00
|
|
|
#define NGX_HTTP_V3_HQ_PROTO "hq-interop"
|
2021-12-06 07:02:36 -03:00
|
|
|
|
2020-03-18 07:46:35 -03:00
|
|
|
#define NGX_HTTP_V3_VARLEN_INT_LEN 4
|
|
|
|
#define NGX_HTTP_V3_PREFIX_INT_LEN 11
|
|
|
|
|
|
|
|
#define NGX_HTTP_V3_STREAM_CONTROL 0x00
|
|
|
|
#define NGX_HTTP_V3_STREAM_PUSH 0x01
|
|
|
|
#define NGX_HTTP_V3_STREAM_ENCODER 0x02
|
|
|
|
#define NGX_HTTP_V3_STREAM_DECODER 0x03
|
|
|
|
|
|
|
|
#define NGX_HTTP_V3_FRAME_DATA 0x00
|
|
|
|
#define NGX_HTTP_V3_FRAME_HEADERS 0x01
|
|
|
|
#define NGX_HTTP_V3_FRAME_CANCEL_PUSH 0x03
|
|
|
|
#define NGX_HTTP_V3_FRAME_SETTINGS 0x04
|
|
|
|
#define NGX_HTTP_V3_FRAME_PUSH_PROMISE 0x05
|
|
|
|
#define NGX_HTTP_V3_FRAME_GOAWAY 0x07
|
|
|
|
#define NGX_HTTP_V3_FRAME_MAX_PUSH_ID 0x0d
|
|
|
|
|
|
|
|
#define NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY 0x01
|
2022-06-08 08:19:01 -04:00
|
|
|
#define NGX_HTTP_V3_PARAM_MAX_FIELD_SECTION_SIZE 0x06
|
2020-03-18 07:46:35 -03:00
|
|
|
#define NGX_HTTP_V3_PARAM_BLOCKED_STREAMS 0x07
|
2020-03-13 13:36:33 -03:00
|
|
|
|
2021-12-06 09:19:54 -03:00
|
|
|
#define NGX_HTTP_V3_MAX_TABLE_CAPACITY 4096
|
|
|
|
|
2020-03-25 06:14:24 -03:00
|
|
|
#define NGX_HTTP_V3_STREAM_CLIENT_CONTROL 0
|
|
|
|
#define NGX_HTTP_V3_STREAM_SERVER_CONTROL 1
|
|
|
|
#define NGX_HTTP_V3_STREAM_CLIENT_ENCODER 2
|
|
|
|
#define NGX_HTTP_V3_STREAM_SERVER_ENCODER 3
|
|
|
|
#define NGX_HTTP_V3_STREAM_CLIENT_DECODER 4
|
|
|
|
#define NGX_HTTP_V3_STREAM_SERVER_DECODER 5
|
|
|
|
#define NGX_HTTP_V3_MAX_KNOWN_STREAM 6
|
2021-12-06 09:19:54 -03:00
|
|
|
#define NGX_HTTP_V3_MAX_UNI_STREAMS 3
|
2020-03-25 06:14:24 -03:00
|
|
|
|
2020-06-30 05:30:57 -04:00
|
|
|
/* HTTP/3 errors */
|
|
|
|
#define NGX_HTTP_V3_ERR_NO_ERROR 0x100
|
|
|
|
#define NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR 0x101
|
|
|
|
#define NGX_HTTP_V3_ERR_INTERNAL_ERROR 0x102
|
|
|
|
#define NGX_HTTP_V3_ERR_STREAM_CREATION_ERROR 0x103
|
|
|
|
#define NGX_HTTP_V3_ERR_CLOSED_CRITICAL_STREAM 0x104
|
|
|
|
#define NGX_HTTP_V3_ERR_FRAME_UNEXPECTED 0x105
|
|
|
|
#define NGX_HTTP_V3_ERR_FRAME_ERROR 0x106
|
|
|
|
#define NGX_HTTP_V3_ERR_EXCESSIVE_LOAD 0x107
|
|
|
|
#define NGX_HTTP_V3_ERR_ID_ERROR 0x108
|
|
|
|
#define NGX_HTTP_V3_ERR_SETTINGS_ERROR 0x109
|
|
|
|
#define NGX_HTTP_V3_ERR_MISSING_SETTINGS 0x10a
|
|
|
|
#define NGX_HTTP_V3_ERR_REQUEST_REJECTED 0x10b
|
|
|
|
#define NGX_HTTP_V3_ERR_REQUEST_CANCELLED 0x10c
|
|
|
|
#define NGX_HTTP_V3_ERR_REQUEST_INCOMPLETE 0x10d
|
|
|
|
#define NGX_HTTP_V3_ERR_CONNECT_ERROR 0x10f
|
|
|
|
#define NGX_HTTP_V3_ERR_VERSION_FALLBACK 0x110
|
|
|
|
|
|
|
|
/* QPACK errors */
|
|
|
|
#define NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED 0x200
|
|
|
|
#define NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR 0x201
|
|
|
|
#define NGX_HTTP_V3_ERR_DECODER_STREAM_ERROR 0x202
|
|
|
|
|
2020-07-02 08:34:05 -04:00
|
|
|
|
2021-12-06 07:02:36 -03:00
|
|
|
#define ngx_http_quic_get_connection(c) \
|
2022-01-31 03:16:47 -03:00
|
|
|
((ngx_http_connection_t *) ((c)->quic ? (c)->quic->parent->data \
|
|
|
|
: (c)->data))
|
2021-12-06 07:02:36 -03:00
|
|
|
|
2021-05-05 07:53:36 -04:00
|
|
|
#define ngx_http_v3_get_session(c) ngx_http_quic_get_connection(c)->v3_session
|
2021-04-30 12:10:11 -04:00
|
|
|
|
2021-03-30 10:48:38 -03:00
|
|
|
#define ngx_http_v3_get_module_loc_conf(c, module) \
|
2021-05-05 07:53:36 -04:00
|
|
|
ngx_http_get_module_loc_conf(ngx_http_quic_get_connection(c)->conf_ctx, \
|
|
|
|
module)
|
2021-03-30 10:48:38 -03:00
|
|
|
|
2020-07-02 08:34:05 -04:00
|
|
|
#define ngx_http_v3_get_module_srv_conf(c, module) \
|
2021-05-05 07:53:36 -04:00
|
|
|
ngx_http_get_module_srv_conf(ngx_http_quic_get_connection(c)->conf_ctx, \
|
|
|
|
module)
|
2020-06-29 08:56:14 -04:00
|
|
|
|
2020-07-02 09:47:51 -04:00
|
|
|
#define ngx_http_v3_finalize_connection(c, code, reason) \
|
2022-01-31 03:16:47 -03:00
|
|
|
ngx_quic_finalize_connection((c)->quic ? (c)->quic->parent : (c), \
|
|
|
|
code, reason)
|
2020-07-02 09:47:51 -04:00
|
|
|
|
2021-03-15 10:39:33 -03:00
|
|
|
#define ngx_http_v3_shutdown_connection(c, code, reason) \
|
2022-01-31 03:16:47 -03:00
|
|
|
ngx_quic_shutdown_connection((c)->quic ? (c)->quic->parent : (c), \
|
|
|
|
code, reason)
|
2021-03-15 10:39:33 -03:00
|
|
|
|
2020-03-13 13:36:33 -03:00
|
|
|
|
2020-03-20 07:47:44 -03:00
|
|
|
typedef struct {
|
2023-02-27 07:00:56 -03:00
|
|
|
ngx_flag_t enable;
|
|
|
|
ngx_flag_t enable_hq;
|
2020-07-02 08:34:05 -04:00
|
|
|
size_t max_table_capacity;
|
|
|
|
ngx_uint_t max_blocked_streams;
|
2020-07-23 06:41:24 -04:00
|
|
|
ngx_uint_t max_concurrent_pushes;
|
2021-12-06 09:19:54 -03:00
|
|
|
ngx_uint_t max_concurrent_streams;
|
2021-12-06 07:02:36 -03:00
|
|
|
ngx_quic_conf_t quic;
|
2020-03-20 07:47:44 -03:00
|
|
|
} ngx_http_v3_srv_conf_t;
|
|
|
|
|
|
|
|
|
2020-07-23 06:41:24 -04:00
|
|
|
typedef struct {
|
|
|
|
ngx_flag_t push_preload;
|
|
|
|
ngx_flag_t push;
|
|
|
|
ngx_array_t *pushes;
|
|
|
|
} ngx_http_v3_loc_conf_t;
|
|
|
|
|
|
|
|
|
2021-02-17 09:56:34 -03:00
|
|
|
struct ngx_http_v3_parse_s {
|
2021-02-17 05:58:32 -03:00
|
|
|
size_t header_limit;
|
2021-02-17 09:56:34 -03:00
|
|
|
ngx_http_v3_parse_headers_t headers;
|
|
|
|
ngx_http_v3_parse_data_t body;
|
2021-12-30 06:59:32 -03:00
|
|
|
ngx_array_t *cookies;
|
2021-02-17 09:56:34 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-05-05 05:54:10 -04:00
|
|
|
struct ngx_http_v3_session_s {
|
2020-07-02 08:34:05 -04:00
|
|
|
ngx_http_v3_dynamic_table_t table;
|
2020-07-23 06:41:24 -04:00
|
|
|
|
2021-03-30 10:48:38 -03:00
|
|
|
ngx_event_t keepalive;
|
|
|
|
ngx_uint_t nrequests;
|
|
|
|
|
2020-07-02 08:34:05 -04:00
|
|
|
ngx_queue_t blocked;
|
|
|
|
ngx_uint_t nblocked;
|
2020-07-23 06:41:24 -04:00
|
|
|
|
|
|
|
ngx_queue_t pushing;
|
|
|
|
ngx_uint_t npushing;
|
|
|
|
uint64_t next_push_id;
|
|
|
|
uint64_t max_push_id;
|
2021-06-11 06:24:24 -04:00
|
|
|
uint64_t goaway_push_id;
|
2022-10-19 10:45:18 -03:00
|
|
|
uint64_t next_request_id;
|
2020-07-23 06:41:24 -04:00
|
|
|
|
2021-10-07 07:22:42 -03:00
|
|
|
off_t total_bytes;
|
|
|
|
off_t payload_bytes;
|
|
|
|
|
2022-10-19 10:45:30 -03:00
|
|
|
unsigned goaway:1;
|
|
|
|
unsigned hq:1;
|
2021-04-16 12:42:03 -04:00
|
|
|
|
2020-07-02 08:34:05 -04:00
|
|
|
ngx_connection_t *known_streams[NGX_HTTP_V3_MAX_KNOWN_STREAM];
|
2021-05-05 07:53:36 -04:00
|
|
|
};
|
2020-03-13 13:36:33 -03:00
|
|
|
|
|
|
|
|
2022-08-22 06:09:03 -04:00
|
|
|
void ngx_http_v3_init_stream(ngx_connection_t *c);
|
|
|
|
void ngx_http_v3_reset_stream(ngx_connection_t *c);
|
2021-05-05 08:09:23 -04:00
|
|
|
ngx_int_t ngx_http_v3_init_session(ngx_connection_t *c);
|
2021-10-07 07:22:42 -03:00
|
|
|
ngx_int_t ngx_http_v3_check_flood(ngx_connection_t *c);
|
2022-11-30 05:51:15 -03:00
|
|
|
ngx_int_t ngx_http_v3_init(ngx_connection_t *c);
|
2022-10-19 10:45:18 -03:00
|
|
|
void ngx_http_v3_shutdown(ngx_connection_t *c);
|
2021-05-05 08:09:23 -04:00
|
|
|
|
2021-01-25 10:16:47 -03:00
|
|
|
ngx_int_t ngx_http_v3_read_request_body(ngx_http_request_t *r);
|
|
|
|
ngx_int_t ngx_http_v3_read_unbuffered_request_body(ngx_http_request_t *r);
|
2020-03-13 13:36:33 -03:00
|
|
|
|
|
|
|
|
|
|
|
extern ngx_module_t ngx_http_v3_module;
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _NGX_HTTP_V3_H_INCLUDED_ */
|