comparison src/event/quic/ngx_event_quic_connection.h @ 8751:bc910a5ec737 quic

QUIC: separate files for output and ack related processing.
author Vladimir Homutov <vl@nginx.com>
date Tue, 13 Apr 2021 14:41:20 +0300
parents 41807e581de9
children e19723c40d28
comparison
equal deleted inserted replaced
8750:41807e581de9 8751:bc910a5ec737
13 13
14 #include <ngx_event_quic_transport.h> 14 #include <ngx_event_quic_transport.h>
15 #include <ngx_event_quic_protection.h> 15 #include <ngx_event_quic_protection.h>
16 16
17 typedef struct ngx_quic_connection_s ngx_quic_connection_t; 17 typedef struct ngx_quic_connection_s ngx_quic_connection_t;
18 typedef struct ngx_quic_send_ctx_s ngx_quic_send_ctx_t;
18 19
19 #include <ngx_event_quic_frames.h> 20 #include <ngx_event_quic_frames.h>
20 #include <ngx_event_quic_migration.h> 21 #include <ngx_event_quic_migration.h>
21 #include <ngx_event_quic_connid.h> 22 #include <ngx_event_quic_connid.h>
22 #include <ngx_event_quic_streams.h> 23 #include <ngx_event_quic_streams.h>
23 24 #include <ngx_event_quic_ack.h>
24 25 #include <ngx_event_quic_output.h>
25 #define NGX_QUIC_MAX_SHORT_HEADER 25 /* 1 flags + 20 dcid + 4 pn */ 26
26 #define NGX_QUIC_MAX_LONG_HEADER 56 27
27 /* 1 flags + 4 version + 2 x (1 + 20) s/dcid + 4 pn + 4 len + token len */
28
29 #define NGX_QUIC_MAX_UDP_PAYLOAD_OUT 1252
30 #define NGX_QUIC_MAX_UDP_PAYLOAD_OUT6 1232
31
32 #define NGX_QUIC_RETRY_TOKEN_LIFETIME 3 /* seconds */
33 #define NGX_QUIC_NEW_TOKEN_LIFETIME 600 /* seconds */
34 #define NGX_QUIC_RETRY_BUFFER_SIZE 256
35 /* 1 flags + 4 version + 3 x (1 + 20) s/o/dcid + itag + token(64) */
36 #define NGX_QUIC_MAX_TOKEN_SIZE 64 28 #define NGX_QUIC_MAX_TOKEN_SIZE 64
37 /* SHA-1(addr)=20 + sizeof(time_t) + retry(1) + odcid.len(1) + odcid */ 29 /* SHA-1(addr)=20 + sizeof(time_t) + retry(1) + odcid.len(1) + odcid */
38 30
39 /* quic-recovery, section 6.2.2, kInitialRtt */ 31 /* quic-recovery, section 6.2.2, kInitialRtt */
40 #define NGX_QUIC_INITIAL_RTT 333 /* ms */ 32 #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 33
51 #define NGX_QUIC_UNSET_PN (uint64_t) -1 34 #define NGX_QUIC_UNSET_PN (uint64_t) -1
52 35
53 #define NGX_QUIC_SEND_CTX_LAST (NGX_QUIC_ENCRYPTION_LAST - 1) 36 #define NGX_QUIC_SEND_CTX_LAST (NGX_QUIC_ENCRYPTION_LAST - 1)
54 37
122 * Conceptually, a packet number space is the context in which a packet 105 * Conceptually, a packet number space is the context in which a packet
123 * can be processed and acknowledged. Initial packets can only be sent 106 * can be processed and acknowledged. Initial packets can only be sent
124 * with Initial packet protection keys and acknowledged in packets which 107 * with Initial packet protection keys and acknowledged in packets which
125 * are also Initial packets. 108 * are also Initial packets.
126 */ 109 */
127 typedef struct { 110 struct ngx_quic_send_ctx_s {
128 enum ssl_encryption_level_t level; 111 enum ssl_encryption_level_t level;
129 112
130 uint64_t pnum; /* to be sent */ 113 uint64_t pnum; /* to be sent */
131 uint64_t largest_ack; /* received from peer */ 114 uint64_t largest_ack; /* received from peer */
132 uint64_t largest_pn; /* received from peer */ 115 uint64_t largest_pn; /* received from peer */
140 ngx_msec_t largest_received; 123 ngx_msec_t largest_received;
141 ngx_msec_t ack_delay_start; 124 ngx_msec_t ack_delay_start;
142 ngx_uint_t nranges; 125 ngx_uint_t nranges;
143 ngx_quic_ack_range_t ranges[NGX_QUIC_MAX_RANGES]; 126 ngx_quic_ack_range_t ranges[NGX_QUIC_MAX_RANGES];
144 ngx_uint_t send_ack; 127 ngx_uint_t send_ack;
145 } ngx_quic_send_ctx_t; 128 };
146 129
147 130
148 struct ngx_quic_connection_s { 131 struct ngx_quic_connection_s {
149 uint32_t version; 132 uint32_t version;
150 133
219 unsigned validated:1; 202 unsigned validated:1;
220 }; 203 };
221 204
222 205
223 void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc); 206 void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc);
224 ngx_msec_t ngx_quic_pto(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx); 207 void ngx_quic_shutdown_quic(ngx_connection_t *c);
225 208
226 ngx_int_t ngx_quic_new_sr_token(ngx_connection_t *c, ngx_str_t *cid, 209 ngx_int_t ngx_quic_new_sr_token(ngx_connection_t *c, ngx_str_t *cid,
227 u_char *secret, u_char *token); 210 u_char *secret, u_char *token);
228 211 ngx_int_t ngx_quic_new_token(ngx_connection_t *c, u_char *key,
229 ngx_int_t ngx_quic_output(ngx_connection_t *c); 212 ngx_str_t *token, ngx_str_t *odcid, time_t expires, ngx_uint_t is_retry);
230 void ngx_quic_shutdown_quic(ngx_connection_t *c);
231 213
232 /********************************* DEBUG *************************************/ 214 /********************************* DEBUG *************************************/
215
216 #if (NGX_DEBUG)
217 void ngx_quic_connstate_dbg(ngx_connection_t *c);
218 #else
219 #define ngx_quic_connstate_dbg(c)
220 #endif
221
233 222
234 /* #define NGX_QUIC_DEBUG_PACKETS */ /* dump packet contents */ 223 /* #define NGX_QUIC_DEBUG_PACKETS */ /* dump packet contents */
235 /* #define NGX_QUIC_DEBUG_FRAMES */ /* dump frames contents */ 224 /* #define NGX_QUIC_DEBUG_FRAMES */ /* dump frames contents */
236 /* #define NGX_QUIC_DEBUG_ALLOC */ /* log frames and bufs alloc */ 225 /* #define NGX_QUIC_DEBUG_ALLOC */ /* log frames and bufs alloc */
237 /* #define NGX_QUIC_DEBUG_CRYPTO */ 226 /* #define NGX_QUIC_DEBUG_CRYPTO */