Mercurial > hg > nginx
comparison src/event/quic/ngx_event_quic_connection.h @ 8736:714e9af983de quic
QUIC: separate header for ngx_quic_connection_t.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 31 Mar 2021 14:56:16 +0300 |
parents | |
children | 76f476ce4d31 |
comparison
equal
deleted
inserted
replaced
8735:9ce6d80df113 | 8736:714e9af983de |
---|---|
1 /* | |
2 * Copyright (C) Nginx, Inc. | |
3 */ | |
4 | |
5 | |
6 #ifndef _NGX_EVENT_QUIC_CONNECTION_H_INCLUDED_ | |
7 #define _NGX_EVENT_QUIC_CONNECTION_H_INCLUDED_ | |
8 | |
9 | |
10 #include <ngx_config.h> | |
11 #include <ngx_core.h> | |
12 #include <ngx_event.h> | |
13 #include <ngx_event_quic_transport.h> | |
14 #include <ngx_event_quic_protection.h> | |
15 | |
16 | |
17 #define NGX_QUIC_SEND_CTX_LAST (NGX_QUIC_ENCRYPTION_LAST - 1) | |
18 | |
19 | |
20 typedef struct ngx_quic_connection_s ngx_quic_connection_t; | |
21 | |
22 | |
23 typedef struct { | |
24 ngx_queue_t queue; | |
25 uint64_t seqnum; | |
26 size_t len; | |
27 u_char id[NGX_QUIC_CID_LEN_MAX]; | |
28 u_char sr_token[NGX_QUIC_SR_TOKEN_LEN]; | |
29 } ngx_quic_client_id_t; | |
30 | |
31 | |
32 typedef struct { | |
33 ngx_udp_connection_t udp; | |
34 ngx_quic_connection_t *quic; | |
35 ngx_queue_t queue; | |
36 uint64_t seqnum; | |
37 size_t len; | |
38 u_char id[NGX_QUIC_CID_LEN_MAX]; | |
39 } ngx_quic_server_id_t; | |
40 | |
41 | |
42 typedef struct { | |
43 ngx_rbtree_t tree; | |
44 ngx_rbtree_node_t sentinel; | |
45 | |
46 uint64_t received; | |
47 uint64_t sent; | |
48 uint64_t recv_max_data; | |
49 uint64_t send_max_data; | |
50 | |
51 uint64_t server_max_streams_uni; | |
52 uint64_t server_max_streams_bidi; | |
53 uint64_t server_streams_uni; | |
54 uint64_t server_streams_bidi; | |
55 | |
56 uint64_t client_max_streams_uni; | |
57 uint64_t client_max_streams_bidi; | |
58 uint64_t client_streams_uni; | |
59 uint64_t client_streams_bidi; | |
60 } ngx_quic_streams_t; | |
61 | |
62 | |
63 typedef struct { | |
64 size_t in_flight; | |
65 size_t window; | |
66 size_t ssthresh; | |
67 ngx_msec_t recovery_start; | |
68 } ngx_quic_congestion_t; | |
69 | |
70 | |
71 /* | |
72 * 12.3. Packet Numbers | |
73 * | |
74 * Conceptually, a packet number space is the context in which a packet | |
75 * can be processed and acknowledged. Initial packets can only be sent | |
76 * with Initial packet protection keys and acknowledged in packets which | |
77 * are also Initial packets. | |
78 */ | |
79 typedef struct { | |
80 enum ssl_encryption_level_t level; | |
81 | |
82 uint64_t pnum; /* to be sent */ | |
83 uint64_t largest_ack; /* received from peer */ | |
84 uint64_t largest_pn; /* received from peer */ | |
85 | |
86 ngx_queue_t frames; | |
87 ngx_queue_t sent; | |
88 | |
89 uint64_t pending_ack; /* non sent ack-eliciting */ | |
90 uint64_t largest_range; | |
91 uint64_t first_range; | |
92 ngx_msec_t largest_received; | |
93 ngx_msec_t ack_delay_start; | |
94 ngx_uint_t nranges; | |
95 ngx_quic_ack_range_t ranges[NGX_QUIC_MAX_RANGES]; | |
96 ngx_uint_t send_ack; | |
97 } ngx_quic_send_ctx_t; | |
98 | |
99 | |
100 struct ngx_quic_connection_s { | |
101 uint32_t version; | |
102 | |
103 ngx_str_t scid; /* initial client ID */ | |
104 ngx_str_t dcid; /* server (our own) ID */ | |
105 ngx_str_t odcid; /* original server ID */ | |
106 | |
107 struct sockaddr *sockaddr; | |
108 socklen_t socklen; | |
109 | |
110 ngx_queue_t client_ids; | |
111 ngx_queue_t server_ids; | |
112 ngx_queue_t free_client_ids; | |
113 ngx_queue_t free_server_ids; | |
114 ngx_uint_t nclient_ids; | |
115 ngx_uint_t nserver_ids; | |
116 uint64_t max_retired_seqnum; | |
117 uint64_t client_seqnum; | |
118 uint64_t server_seqnum; | |
119 | |
120 ngx_uint_t client_tp_done; | |
121 ngx_quic_tp_t tp; | |
122 ngx_quic_tp_t ctp; | |
123 | |
124 ngx_quic_send_ctx_t send_ctx[NGX_QUIC_SEND_CTX_LAST]; | |
125 | |
126 ngx_quic_frames_stream_t crypto[NGX_QUIC_ENCRYPTION_LAST]; | |
127 | |
128 ngx_quic_keys_t *keys; | |
129 | |
130 ngx_quic_conf_t *conf; | |
131 | |
132 ngx_event_t push; | |
133 ngx_event_t pto; | |
134 ngx_event_t close; | |
135 ngx_msec_t last_cc; | |
136 | |
137 ngx_msec_t latest_rtt; | |
138 ngx_msec_t avg_rtt; | |
139 ngx_msec_t min_rtt; | |
140 ngx_msec_t rttvar; | |
141 | |
142 ngx_uint_t pto_count; | |
143 | |
144 ngx_queue_t free_frames; | |
145 ngx_chain_t *free_bufs; | |
146 ngx_buf_t *free_shadow_bufs; | |
147 | |
148 #ifdef NGX_QUIC_DEBUG_ALLOC | |
149 ngx_uint_t nframes; | |
150 ngx_uint_t nbufs; | |
151 #endif | |
152 | |
153 ngx_quic_streams_t streams; | |
154 ngx_quic_congestion_t congestion; | |
155 off_t received; | |
156 | |
157 ngx_uint_t error; | |
158 enum ssl_encryption_level_t error_level; | |
159 ngx_uint_t error_ftype; | |
160 const char *error_reason; | |
161 | |
162 ngx_uint_t shutdown_code; | |
163 const char *shutdown_reason; | |
164 | |
165 unsigned error_app:1; | |
166 unsigned send_timer_set:1; | |
167 unsigned closing:1; | |
168 unsigned shutdown:1; | |
169 unsigned draining:1; | |
170 unsigned key_phase:1; | |
171 unsigned validated:1; | |
172 }; | |
173 | |
174 | |
175 ngx_quic_frame_t *ngx_quic_alloc_frame(ngx_connection_t *c); | |
176 void ngx_quic_queue_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *frame); | |
177 void ngx_quic_close_connection(ngx_connection_t *c, ngx_int_t rc); | |
178 | |
179 #endif |