comparison src/http/v3/ngx_http_v3.h @ 8226:268f4389130d quic

Refactored HTTP/3 parser.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 18 Mar 2020 13:46:35 +0300
parents 38c0898b6df7
children e9891e8ee975
comparison
equal deleted inserted replaced
8225:714a19dba6af 8226:268f4389130d
10 10
11 11
12 #include <ngx_config.h> 12 #include <ngx_config.h>
13 #include <ngx_core.h> 13 #include <ngx_core.h>
14 #include <ngx_http.h> 14 #include <ngx_http.h>
15 #include <ngx_http_v3_parse.h>
15 16
16 17
17 #define NGX_HTTP_V3_STREAM 0x48335354 /* "H3ST" */ 18 #define NGX_HTTP_V3_STREAM 0x48335354 /* "H3ST" */
18 19
19 20
20 #define NGX_HTTP_V3_VARLEN_INT_LEN 4 21 #define NGX_HTTP_V3_VARLEN_INT_LEN 4
21 #define NGX_HTTP_V3_PREFIX_INT_LEN 11 22 #define NGX_HTTP_V3_PREFIX_INT_LEN 11
23
24 #define NGX_HTTP_V3_STREAM_CONTROL 0x00
25 #define NGX_HTTP_V3_STREAM_PUSH 0x01
26 #define NGX_HTTP_V3_STREAM_ENCODER 0x02
27 #define NGX_HTTP_V3_STREAM_DECODER 0x03
28
29 #define NGX_HTTP_V3_FRAME_DATA 0x00
30 #define NGX_HTTP_V3_FRAME_HEADERS 0x01
31 #define NGX_HTTP_V3_FRAME_CANCEL_PUSH 0x03
32 #define NGX_HTTP_V3_FRAME_SETTINGS 0x04
33 #define NGX_HTTP_V3_FRAME_PUSH_PROMISE 0x05
34 #define NGX_HTTP_V3_FRAME_GOAWAY 0x07
35 #define NGX_HTTP_V3_FRAME_MAX_PUSH_ID 0x0d
36
37 #define NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY 0x01
38 #define NGX_HTTP_V3_PARAM_MAX_HEADER_LIST_SIZE 0x06
39 #define NGX_HTTP_V3_PARAM_BLOCKED_STREAMS 0x07
22 40
23 41
24 typedef struct { 42 typedef struct {
25 ngx_http_connection_t hc; 43 ngx_http_connection_t hc;
26 44
27 ngx_array_t *dynamic; 45 ngx_array_t *dynamic;
28 46
29 ngx_connection_t *client_encoder; 47 ngx_connection_t *client_encoder;
30 ngx_connection_t *client_decoder; 48 ngx_connection_t *client_decoder;
49 ngx_connection_t *client_control;
50
31 ngx_connection_t *server_encoder; 51 ngx_connection_t *server_encoder;
32 ngx_connection_t *server_decoder; 52 ngx_connection_t *server_decoder;
53 ngx_connection_t *server_control;
33 } ngx_http_v3_connection_t; 54 } ngx_http_v3_connection_t;
34 55
35 56
36 typedef struct { 57 typedef struct {
37 ngx_str_t name; 58 ngx_str_t name;
38 ngx_str_t value; 59 ngx_str_t value;
39 } ngx_http_v3_header_t; 60 } ngx_http_v3_header_t;
40 61
41 62
42 ngx_int_t ngx_http_v3_parse_header(ngx_http_request_t *r, ngx_buf_t *b, 63 ngx_int_t ngx_http_v3_parse_header(ngx_http_request_t *r, ngx_buf_t *b);
43 ngx_uint_t pseudo);
44 ngx_chain_t *ngx_http_v3_create_header(ngx_http_request_t *r); 64 ngx_chain_t *ngx_http_v3_create_header(ngx_http_request_t *r);
45
46 65
47 uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value); 66 uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value);
48 uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value, 67 uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value,
49 ngx_uint_t prefix); 68 ngx_uint_t prefix);
50 uint64_t ngx_http_v3_decode_varlen_int(u_char *p);
51 int64_t ngx_http_v3_decode_prefix_int(u_char **src, size_t len,
52 ngx_uint_t prefix);
53 ngx_int_t ngx_http_v3_decode_huffman(ngx_connection_t *c, ngx_str_t *s);
54 69
55 void ngx_http_v3_handle_client_uni_stream(ngx_connection_t *c); 70 void ngx_http_v3_handle_client_uni_stream(ngx_connection_t *c);
56 71
57 ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, 72 ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic,
58 ngx_uint_t index, ngx_str_t *value); 73 ngx_uint_t index, ngx_str_t *value);
65 ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc); 80 ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc);
66 ngx_http_v3_header_t *ngx_http_v3_lookup_table(ngx_connection_t *c, 81 ngx_http_v3_header_t *ngx_http_v3_lookup_table(ngx_connection_t *c,
67 ngx_uint_t dynamic, ngx_uint_t index); 82 ngx_uint_t dynamic, ngx_uint_t index);
68 ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c, 83 ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c,
69 ngx_uint_t insert_count); 84 ngx_uint_t insert_count);
85 ngx_int_t ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id,
86 uint64_t value);
70 87
71 ngx_int_t ngx_http_v3_client_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, 88 ngx_int_t ngx_http_v3_client_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic,
72 ngx_uint_t index, ngx_str_t *value); 89 ngx_uint_t index, ngx_str_t *value);
73 ngx_int_t ngx_http_v3_client_insert(ngx_connection_t *c, ngx_str_t *name, 90 ngx_int_t ngx_http_v3_client_insert(ngx_connection_t *c, ngx_str_t *name,
74 ngx_str_t *value); 91 ngx_str_t *value);