comparison src/event/ngx_event_quic.c @ 8235:552d6868091b quic

Implemented send_alert callback, CONNECTION_CLOSE writer. The callback produces a CONNECTION_CLOSE frame, as per quic-tls-24#section-4.9.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 18 Mar 2020 23:07:40 +0300
parents 19bb9edcd8bd
children d3b26c3bea22
comparison
equal deleted inserted replaced
8234:19bb9edcd8bd 8235:552d6868091b
249 static int 249 static int
250 ngx_quic_send_alert(ngx_ssl_conn_t *ssl_conn, enum ssl_encryption_level_t level, 250 ngx_quic_send_alert(ngx_ssl_conn_t *ssl_conn, enum ssl_encryption_level_t level,
251 uint8_t alert) 251 uint8_t alert)
252 { 252 {
253 ngx_connection_t *c; 253 ngx_connection_t *c;
254 ngx_quic_frame_t *frame;
254 255
255 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn); 256 c = ngx_ssl_get_connection((ngx_ssl_conn_t *) ssl_conn);
256 257
257 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 258 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
258 "ngx_quic_send_alert(), lvl=%d, alert=%d", 259 "ngx_quic_send_alert(), lvl=%d, alert=%d",
259 (int) level, (int) alert); 260 (int) level, (int) alert);
261
262 frame = ngx_pcalloc(c->pool, sizeof(ngx_quic_frame_t));
263 if (frame == NULL) {
264 return 0;
265 }
266
267 frame->level = level;
268 frame->type = NGX_QUIC_FT_CONNECTION_CLOSE;
269 frame->u.close.error_code = 0x100 + alert;
270
271 ngx_quic_queue_frame(c->quic, frame);
272
273 if (ngx_quic_output(c) != NGX_OK) {
274 return 0;
275 }
260 276
261 return 1; 277 return 1;
262 } 278 }
263 279
264 280