comparison src/event/quic/ngx_event_quic.h @ 8673:046c951e393a quic

QUIC: moved all quic sources into src/event/quic.
author Vladimir Homutov <vl@nginx.com>
date Fri, 25 Dec 2020 14:01:28 +0300
parents src/event/ngx_event_quic.h@2dfc5ef29973
children dffb66fb783b
comparison
equal deleted inserted replaced
8672:13c537def699 8673:046c951e393a
1
2 /*
3 * Copyright (C) Nginx, Inc.
4 */
5
6
7 #ifndef _NGX_EVENT_QUIC_H_INCLUDED_
8 #define _NGX_EVENT_QUIC_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13
14
15 /* Supported drafts: 27, 28, 29 */
16 #ifndef NGX_QUIC_DRAFT_VERSION
17 #define NGX_QUIC_DRAFT_VERSION 29
18 #endif
19
20 #define NGX_QUIC_MAX_SHORT_HEADER 25 /* 1 flags + 20 dcid + 4 pn */
21 #define NGX_QUIC_MAX_LONG_HEADER 56
22 /* 1 flags + 4 version + 2 x (1 + 20) s/dcid + 4 pn + 4 len + token len */
23
24 #define NGX_QUIC_MAX_UDP_PAYLOAD_SIZE 65527
25 #define NGX_QUIC_MAX_UDP_PAYLOAD_OUT 1252
26 #define NGX_QUIC_MAX_UDP_PAYLOAD_OUT6 1232
27
28 #define NGX_QUIC_DEFAULT_ACK_DELAY_EXPONENT 3
29 #define NGX_QUIC_DEFAULT_MAX_ACK_DELAY 25
30 #define NGX_QUIC_DEFAULT_SRT_KEY_LEN 32
31
32 #define NGX_QUIC_RETRY_TIMEOUT 3000
33 #define NGX_QUIC_RETRY_LIFETIME 30000
34 #define NGX_QUIC_RETRY_BUFFER_SIZE 128
35 /* 1 flags + 4 version + 3 x (1 + 20) s/o/dcid + itag + token(44) */
36 #define NGX_QUIC_MAX_TOKEN_SIZE 32
37 /* sizeof(struct in6_addr) + sizeof(ngx_msec_t) up to AES-256 block size */
38
39 /* quic-recovery, section 6.2.2, kInitialRtt */
40 #define NGX_QUIC_INITIAL_RTT 333 /* ms */
41
42 /* quic-recovery, section 6.1.1, Packet Threshold */
43 #define NGX_QUIC_PKT_THR 3 /* packets */
44 /* quic-recovery, section 6.1.2, Time Threshold */
45 #define NGX_QUIC_TIME_THR 1.125
46 #define NGX_QUIC_TIME_GRANULARITY 1 /* ms */
47
48 #define NGX_QUIC_CC_MIN_INTERVAL 1000 /* 1s */
49
50 #define NGX_QUIC_MIN_INITIAL_SIZE 1200
51
52 #define NGX_QUIC_STREAM_SERVER_INITIATED 0x01
53 #define NGX_QUIC_STREAM_UNIDIRECTIONAL 0x02
54
55 #define NGX_QUIC_STREAM_BUFSIZE 65536
56
57 #define NGX_QUIC_MAX_CID_LEN 20
58 #define NGX_QUIC_SERVER_CID_LEN NGX_QUIC_MAX_CID_LEN
59
60 #define NGX_QUIC_SR_TOKEN_LEN 16
61
62 #define NGX_QUIC_MAX_SERVER_IDS 8
63
64 #define NGX_QUIC_BUFFER_SIZE 4096
65
66 #define ngx_quic_get_connection(c) ((ngx_quic_connection_t *)(c)->udp)
67
68
69 typedef struct {
70 /* configurable */
71 ngx_msec_t max_idle_timeout;
72 ngx_msec_t max_ack_delay;
73
74 size_t max_udp_payload_size;
75 size_t initial_max_data;
76 size_t initial_max_stream_data_bidi_local;
77 size_t initial_max_stream_data_bidi_remote;
78 size_t initial_max_stream_data_uni;
79 ngx_uint_t initial_max_streams_bidi;
80 ngx_uint_t initial_max_streams_uni;
81 ngx_uint_t ack_delay_exponent;
82 ngx_uint_t active_connection_id_limit;
83 ngx_flag_t disable_active_migration;
84 ngx_str_t original_dcid;
85 ngx_str_t initial_scid;
86 ngx_str_t retry_scid;
87 u_char sr_token[NGX_QUIC_SR_TOKEN_LEN];
88
89 /* TODO */
90 void *preferred_address;
91 } ngx_quic_tp_t;
92
93
94 typedef struct {
95 ngx_ssl_t *ssl;
96 ngx_quic_tp_t tp;
97 ngx_flag_t retry;
98 ngx_flag_t require_alpn;
99 u_char token_key[32]; /* AES 256 */
100 ngx_str_t sr_token_key; /* stateless reset token key */
101 } ngx_quic_conf_t;
102
103
104 typedef struct {
105 uint64_t sent;
106 uint64_t received;
107 ngx_queue_t frames; /* reorder queue */
108 size_t total; /* size of buffered data */
109 } ngx_quic_frames_stream_t;
110
111
112 struct ngx_quic_stream_s {
113 ngx_rbtree_node_t node;
114 ngx_connection_t *parent;
115 ngx_connection_t *c;
116 uint64_t id;
117 uint64_t acked;
118 uint64_t send_max_data;
119 ngx_buf_t *b;
120 ngx_quic_frames_stream_t fs;
121 };
122
123
124 typedef struct ngx_quic_keys_s ngx_quic_keys_t;
125
126
127 void ngx_quic_run(ngx_connection_t *c, ngx_quic_conf_t *conf);
128 ngx_connection_t *ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi);
129 void ngx_quic_finalize_connection(ngx_connection_t *c, ngx_uint_t err,
130 const char *reason);
131 uint32_t ngx_quic_version(ngx_connection_t *c);
132 ngx_int_t ngx_quic_get_packet_dcid(ngx_log_t *log, u_char *data, size_t len,
133 ngx_str_t *dcid);
134
135
136 /********************************* DEBUG *************************************/
137
138 /* #define NGX_QUIC_DEBUG_PACKETS */ /* dump packet contents */
139 /* #define NGX_QUIC_DEBUG_FRAMES */ /* dump frames contents */
140 /* #define NGX_QUIC_DEBUG_ALLOC */ /* log frames and bufs alloc */
141 /* #define NGX_QUIC_DEBUG_CRYPTO */
142
143 #endif /* _NGX_EVENT_QUIC_H_INCLUDED_ */