comparison src/event/ngx_event_quic.c @ 8260:f388c0ad3477 quic

Added processing of client transport parameters. note: + parameters are available in SSL connection since they are obtained by ssl stack quote: During connection establishment, both endpoints make authenticated declarations of their transport parameters. These declarations are made unilaterally by each endpoint. and really, we send our parameters before we read client's. no handling of incoming parameters is made by this patch.
author Vladimir Homutov <vl@nginx.com>
date Sat, 21 Mar 2020 20:51:59 +0300
parents 9e9eab876964
children 1295b293d09a
comparison
equal deleted inserted replaced
8259:9e9eab876964 8260:f388c0ad3477
30 struct ngx_quic_connection_s { 30 struct ngx_quic_connection_s {
31 ngx_str_t scid; 31 ngx_str_t scid;
32 ngx_str_t dcid; 32 ngx_str_t dcid;
33 ngx_str_t token; 33 ngx_str_t token;
34 34
35 ngx_uint_t client_tp_done;
35 ngx_quic_tp_t tp; 36 ngx_quic_tp_t tp;
36 37
37 /* current packet numbers for each namespace */ 38 /* current packet numbers for each namespace */
38 ngx_uint_t initial_pn; 39 ngx_uint_t initial_pn;
39 ngx_uint_t handshake_pn; 40 ngx_uint_t handshake_pn;
204 205
205 static int 206 static int
206 ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn, 207 ngx_quic_add_handshake_data(ngx_ssl_conn_t *ssl_conn,
207 enum ssl_encryption_level_t level, const uint8_t *data, size_t len) 208 enum ssl_encryption_level_t level, const uint8_t *data, size_t len)
208 { 209 {
209 u_char *p; 210 u_char *p, *end;
211 size_t client_params_len;
212 const uint8_t *client_params;
213 ngx_quic_tp_t ctp;
210 ngx_quic_frame_t *frame; 214 ngx_quic_frame_t *frame;
211 ngx_connection_t *c; 215 ngx_connection_t *c;
212 ngx_quic_connection_t *qc; 216 ngx_quic_connection_t *qc;
213 217
214 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); 218 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
215 qc = c->quic; 219 qc = c->quic;
216 220
217 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, 221 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
218 "ngx_quic_add_handshake_data"); 222 "ngx_quic_add_handshake_data");
223
224 /* XXX: obtain client parameters after the handshake? */
225 if (!qc->client_tp_done) {
226
227 SSL_get_peer_quic_transport_params(ssl_conn, &client_params,
228 &client_params_len);
229
230 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
231 "SSL_get_peer_quic_transport_params(): params_len %ui",
232 client_params_len);
233
234 if (client_params_len != 0) {
235 p = (u_char *) client_params;
236 end = p + client_params_len;
237
238 ngx_memzero(&ctp, sizeof(ngx_quic_tp_t));
239
240 if (ngx_quic_parse_transport_params(p, end, &ctp, c->log) != NGX_OK)
241 {
242 return NGX_ERROR;
243 }
244
245 /* TODO: save/use obtained client parameters: merge with ours? */
246
247 qc->client_tp_done = 1;
248 }
249 }
219 250
220 frame = ngx_pcalloc(c->pool, sizeof(ngx_quic_frame_t)); 251 frame = ngx_pcalloc(c->pool, sizeof(ngx_quic_frame_t));
221 if (frame == NULL) { 252 if (frame == NULL) {
222 return 0; 253 return 0;
223 } 254 }